class AuthorizationController

Traits

Methods

Response
convertResponse(ResponseInterface $psrResponse)

Convert a PSR-7 response to a Symfony response.

mixed
withErrorHandling(Closure $callback)

Perform the given callback with exception handling.

mixed
withAuthorizationErrorHandling(Closure $callback, array $pending, AuthorizationResponse $responses)

Render authorization errors after rollback using the validated interaction context.

getApprovingGuard()

Resolve the guard authorizing the current request.

string
getApprovingGuardName()

Get the name of the guard authorizing the current request.

string|null
getApprovingProvider()

Get the approving guard's user provider.

array
authorizationState(Request $request, array $parameters, Authenticatable $user, Client $client, array $scopes, AuthorizationRequestInterface|DeviceCodeEntityInterface $authorization, Dispatcher $events)

Capture the approving identity and synchronous extension decisions.

void
ensureApprovingUser(array $pending)

Ensure the consent belongs to the current user and provider.

array
getPendingAuthorization(Request $request)

Get the pending interaction selected by a browser decision.

getClientForApproval(string $identifier, string $grantType, array $scopes)

Recheck the client and scopes saved with the consent request.

__construct(ServerFactory $servers, AuthManager $auth, ClientRepository $clients, Repository $config, AuthorizationRequestResolver $authorizations, PendingAuthorizationRepository $pending, ConsentRepository $consents, AuthorizationFinalizer $finalizer, AuthorizationResponse $responses, Dispatcher $events, PushedAuthorizationRequestRepository $pushed)

Create a new controller instance.

Response
store(Request $request)

Turn a cross-site protocol form into a top-level GET without touching its session.

authorize(ServerRequestInterface $psrRequest, Request $request, ResponseInterface $psrResponse, AuthorizationViewResponse $viewResponse)

Authorize a client to access the user's account.

resume(string $authorization, Request $request, ServerRequestInterface $psrRequest, ResponseInterface $psrResponse, AuthorizationViewResponse $viewResponse)

Resume a browser interaction without accepting replacement protocol parameters.

Response
continueAsCurrentAccount(Request $request)

Continue a pending authorization as the explicitly selected account.

Response
switchAccount(Request $request)

Sign out for an explicit account switch while preserving only this authorization.

respondToAuthorization(Request $request, ServerRequestInterface $psrRequest, AuthorizationRequestInterface $authRequest, ResponseInterface $psrResponse, AuthorizationViewResponse $viewResponse, array $pending, string|null $authorization = null)

Resolve login, account choice and consent for a validated authorization.

string
saveAuthorization(Request $request, string|null $authorization, array $pending)

Save a new interaction or advance it without extending its lifetime.

array
parseScopes(AuthorizationRequestInterface $authRequest)

Transform the authorization request's scopes into Scope instances.

bool
hasGrantedScopes(Authenticatable $user, Client $client, array $scopes, array $permissions = [])

Determine if the given user has already granted the client access to the scopes.

Response
approveRequest(AuthorizationRequestInterface $authRequest, ResponseInterface $psrResponse)

Approve the authorization request.

never
promptForLogin(Request $request)

Prompt the user to login by throwing an AuthenticationException.

Details

Response convertResponse(ResponseInterface $psrResponse)

Convert a PSR-7 response to a Symfony response.

Parameters

ResponseInterface $psrResponse

Return Value

Response

in HandlesOAuthErrors at line 25
protected mixed withErrorHandling(Closure $callback)

Perform the given callback with exception handling.

Parameters

Closure $callback

Return Value

mixed

Exceptions

OAuthServerException

in HandlesOAuthErrors at line 42
protected mixed withAuthorizationErrorHandling(Closure $callback, array $pending, AuthorizationResponse $responses)

Render authorization errors after rollback using the validated interaction context.

Parameters

Closure $callback
array $pending
AuthorizationResponse $responses

Return Value

mixed

protected StatefulGuard getApprovingGuard()

Resolve the guard authorizing the current request.

Return Value

StatefulGuard

protected string getApprovingGuardName()

Get the name of the guard authorizing the current request.

Return Value

string

protected string|null getApprovingProvider()

Get the approving guard's user provider.

Return Value

string|null

protected array authorizationState(Request $request, array $parameters, Authenticatable $user, Client $client, array $scopes, AuthorizationRequestInterface|DeviceCodeEntityInterface $authorization, Dispatcher $events)

Capture the approving identity and synchronous extension decisions.

Parameters

Request $request
array $parameters
Authenticatable $user
Client $client
array $scopes
AuthorizationRequestInterface|DeviceCodeEntityInterface $authorization
Dispatcher $events

Return Value

array

protected void ensureApprovingUser(array $pending)

Ensure the consent belongs to the current user and provider.

Parameters

array $pending

Return Value

void

protected array getPendingAuthorization(Request $request)

Get the pending interaction selected by a browser decision.

Parameters

Request $request

Return Value

array

protected Client getClientForApproval(string $identifier, string $grantType, array $scopes)

Recheck the client and scopes saved with the consent request.

Parameters

string $identifier
string $grantType
array $scopes

Return Value

Client

at line 56
__construct(ServerFactory $servers, AuthManager $auth, ClientRepository $clients, Repository $config, AuthorizationRequestResolver $authorizations, PendingAuthorizationRepository $pending, ConsentRepository $consents, AuthorizationFinalizer $finalizer, AuthorizationResponse $responses, Dispatcher $events, PushedAuthorizationRequestRepository $pushed)

Create a new controller instance.

at line 74
Response store(Request $request)

Turn a cross-site protocol form into a top-level GET without touching its session.

Parameters

Request $request

Return Value

Response

at line 86
Response|AuthorizationViewResponse authorize(ServerRequestInterface $psrRequest, Request $request, ResponseInterface $psrResponse, AuthorizationViewResponse $viewResponse)

Authorize a client to access the user's account.

Parameters

ServerRequestInterface $psrRequest
Request $request
ResponseInterface $psrResponse
AuthorizationViewResponse $viewResponse

Return Value

Response|AuthorizationViewResponse

at line 132
Response|AuthorizationViewResponse resume(string $authorization, Request $request, ServerRequestInterface $psrRequest, ResponseInterface $psrResponse, AuthorizationViewResponse $viewResponse)

Resume a browser interaction without accepting replacement protocol parameters.

Parameters

string $authorization
Request $request
ServerRequestInterface $psrRequest
ResponseInterface $psrResponse
AuthorizationViewResponse $viewResponse

Return Value

Response|AuthorizationViewResponse

at line 168
Response continueAsCurrentAccount(Request $request)

Continue a pending authorization as the explicitly selected account.

Parameters

Request $request

Return Value

Response

at line 186
Response switchAccount(Request $request)

Sign out for an explicit account switch while preserving only this authorization.

Parameters

Request $request

Return Value

Response

at line 213
protected Response|AuthorizationViewResponse respondToAuthorization(Request $request, ServerRequestInterface $psrRequest, AuthorizationRequestInterface $authRequest, ResponseInterface $psrResponse, AuthorizationViewResponse $viewResponse, array $pending, string|null $authorization = null)

Resolve login, account choice and consent for a validated authorization.

Parameters

Request $request
ServerRequestInterface $psrRequest
AuthorizationRequestInterface $authRequest
ResponseInterface $psrResponse
AuthorizationViewResponse $viewResponse
array $pending
string|null $authorization

Return Value

Response|AuthorizationViewResponse

at line 372
protected string saveAuthorization(Request $request, string|null $authorization, array $pending)

Save a new interaction or advance it without extending its lifetime.

Parameters

Request $request
string|null $authorization
array $pending

Return Value

string

at line 388
protected array parseScopes(AuthorizationRequestInterface $authRequest)

Transform the authorization request's scopes into Scope instances.

Parameters

AuthorizationRequestInterface $authRequest

Return Value

array

at line 407
protected bool hasGrantedScopes(Authenticatable $user, Client $client, array $scopes, array $permissions = [])

Determine if the given user has already granted the client access to the scopes.

This pre-check does not replace the final locked consent check. Customize Consent::covers() for remembered coverage, or Client::skipsAuthorization() for trusted approval without remembered consent.

Parameters

Authenticatable $user
Client $client
array $scopes
array $permissions

Return Value

bool

at line 421
protected Response approveRequest(AuthorizationRequestInterface $authRequest, ResponseInterface $psrResponse)

Approve the authorization request.

Parameters

AuthorizationRequestInterface $authRequest
ResponseInterface $psrResponse

Return Value

Response

at line 435
protected never promptForLogin(Request $request)

Prompt the user to login by throwing an AuthenticationException.

Parameters

Request $request

Return Value

never

Exceptions

AuthenticationException