Passport
class Passport
Constants
| DEFAULT_GUARD |
|
| DEFAULT_COOKIE |
|
| REGISTRATION_SCOPE |
|
| protected DEFAULT_VALIDATE_KEY_PERMISSIONS |
|
| protected DEFAULT_REVOKE_REFRESH_TOKEN_AFTER_USE |
|
| protected DEFAULT_DEVICE_CODE_GRANT_ENABLED |
|
| protected DEFAULT_SCOPE |
|
| protected DEFAULT_SCOPES |
|
| protected DEFAULT_RESOURCES |
|
| protected DEFAULT_IGNORE_CSRF_TOKEN |
|
| protected DEFAULT_ACCESS_TOKEN_ENTITY |
|
| protected DEFAULT_AUTH_CODE_MODEL |
|
| protected DEFAULT_PUSHED_AUTHORIZATION_REQUEST_MODEL |
|
| protected DEFAULT_DEVICE_CODE_MODEL |
|
| protected DEFAULT_CLIENT_MODEL |
|
| protected DEFAULT_CONSENT_MODEL |
|
| protected DEFAULT_TOKEN_MODEL |
|
| protected DEFAULT_REFRESH_TOKEN_MODEL |
|
| protected DEFAULT_REFRESH_TOKEN_FAMILY_MODEL |
|
| protected DEFAULT_SIGNING_KEY_MODEL |
|
| protected DEFAULT_UNSERIALIZES_COOKIES |
|
| protected DEFAULT_DECRYPTS_COOKIES |
|
| protected DEFAULT_WITH_INHERITED_SCOPES |
|
| protected DEFAULT_REGISTERS_ROUTES |
|
| protected DEFAULT_DYNAMIC_CLIENT_REGISTRATION_ENABLED |
|
| protected DEFAULT_INHERITED_GRANT_ATTRIBUTES |
|
Properties
| static bool | $validateKeyPermissions | Indicates if Passport should validate the permissions of its encryption keys. |
|
| static bool | $revokeRefreshTokenAfterUse | Indicates if the refresh token should be revoked after use. |
|
| static bool | $deviceCodeGrantEnabled | Indicates if the device authorization grant type is enabled. |
|
| static string | $defaultScope | The default scope. |
|
| static array<string, string> | $scopes | All of the scopes defined for the application. |
|
| static protected array<string, string> | $resources | ||
| static DateInterval|null | $tokensExpireIn | The interval when access tokens expire. |
|
| static DateInterval|null | $refreshTokensExpireIn | The date when refresh tokens expire. |
|
| static DateInterval|null | $personalAccessTokensExpireIn | The date when personal access tokens expire. |
|
| static DateInterval|null | $clientCredentialsTokensExpireIn | The interval when client credentials tokens expire. |
|
| static DateInterval|null | $dpopTokensExpireIn | The maximum lifetime of proof-bound access tokens. |
|
| static DateInterval|null | $rememberConsentFor | The interval for remembering user approval, or null for indefinite approval. |
|
| static string | $cookie | The name for API token cookies. |
|
| static bool | $ignoreCsrfToken | Indicates if Passport should ignore incoming CSRF tokens. |
|
| static string|null | $keyPath | The storage location of the encryption keys. |
|
| static AccessToken> | $accessTokenEntity | The access token entity class name. |
|
| static AuthCode> | $authCodeModel | The auth code model class name. |
|
| static DeviceCode> | $deviceCodeModel | The device code model class name. |
|
| static Client> | $clientModel | The client model class name. |
|
| static Consent> | $consentModel | The consent model class name. |
|
| static PushedAuthorizationRequest> | $pushedAuthorizationRequestModel | The pushed authorization request model class name. |
|
| static Token> | $tokenModel | The token model class name. |
|
| static RefreshToken> | $refreshTokenModel | The refresh token model class name. |
|
| static RefreshTokenFamily> | $refreshTokenFamilyModel | The refresh token family model class name. |
|
| static SigningKey> | $signingKeyModel | The signing key model class name. |
|
| static bool | $unserializesCookies | Indicate if Passport should unserialize cookies. |
|
| static bool | $decryptsCookies | Indicates if Passport should decrypt cookies. |
|
| static null|Encrypter): string | $tokenEncryptionKeyCallback | The callback that should be used to generate JWT encryption keys. |
|
| static bool | $withInheritedScopes | Indicates the scope should inherit its parent scope. |
|
| static ResponseTypeInterface|null | $authorizationServerResponseType | The authorization server response type. |
|
| static bool | $registersRoutes | Indicates if Passport routes will be registered. |
|
| static bool | $dynamicClientRegistrationEnabled | Indicates if the dynamic client registration endpoint is enabled. |
|
| static null|Token, bool): bool | $accessTokenAuthenticationCallback | The callback used to authenticate access tokens. |
|
| static null|Client): bool | $clientAuthenticationCallback | The callback used to authenticate clients. |
|
| static null|Token): bool | $introspectionAuthorizationCallback | The callback authorizing another client to inspect an access token. |
|
| static null|Request): ?string | $resourceMetadataCallback | The callback resolving protected-resource discovery for an authentication challenge. |
|
| static list<string> | $inheritedGrantAttributes | The grant attributes inherited by issued credentials. |
|
| static null|Request): ?string | $cookieBindingCallback | The callback used to bind API cookies to the current request. |
|
| static null|Token): array<string, mixed> | $accessTokenClaimsCallback | The callback used to add access token claims. |
|
| static null|Token): bool | $issueRefreshTokensCallback | The callback used to determine whether a refresh token may be issued. |
Methods
Set or get the default scopes.
Return the scopes in the given list that are actually defined scopes for the application.
Get all of the defined scope IDs.
Determine if the given scope has been defined.
Get all of the scopes defined for the application.
Get all of the scopes matching the given IDs.
Get the global scopes and any scopes belonging to the current server.
Define the scopes for the application.
Define the resources tokens may access.
Determine whether a resource has been defined.
Get the resources matching the given identifiers.
Get the global resources and those belonging to the current server.
Get or set how long user approval is remembered.
Get or set when access tokens expire.
Get or set when refresh tokens expire.
Get or set when personal access tokens expire.
Get or set when client credentials grant tokens expire.
Get or set the maximum lifetime of proof-bound access tokens.
Get or set the name for API token cookies.
Indicate that Passport should ignore incoming CSRF tokens.
Set the current user for the application with the given scopes.
Set the current client for the application with the given scopes.
Get the provider for personal access clients without an explicit provider.
Set the storage location of the encryption keys.
Get the location of the encryption keys.
Set the access token entity class name.
Set the consent model class name.
Get the consent model class name.
Set the auth code model class name.
Get the auth code model class name.
Set the pushed authorization request model class name.
Get the pushed authorization request model class name.
Get a new pushed authorization request model instance.
Set the default ResponseType that should be used by the authorization server.
Set the device code model class name.
Get the device code model class name.
Get a new device code model instance.
Set the client model class name.
Get the client model class name.
Set the token model class name.
Get the token model class name.
Set the refresh token model class name.
Get the refresh token model class name.
Get a new refresh token model instance.
Set the refresh token family model class name.
Get the refresh token family model class name.
Get a new refresh token family model instance.
Set the signing key model class name.
Get the signing key model class name.
Get a new signing key model instance.
Specify an additional access token authentication check.
Authorize resource-server clients to inspect another client's access token.
Specify the callback resolving protected-resource metadata for authentication challenges.
Specify grant attributes to carry into issued tokens.
Specify the binding included in and checked against API cookies.
Specify whether an access token may receive a refresh token.
Specify the callback that should be invoked to generate encryption keys for encrypting JWT tokens.
Register the views for Passport using conventional names under the given namespace.
Register the views for Passport using conventional names under the given prefix.
Specify which view should be used as the authorization view.
Specify which view should be used to select the approving account.
Specify which view should be used as the device authorization view.
Specify which view should be used as the device user code view.
Configure Passport to not register its routes.
Enable the dynamic client registration endpoint.
Instruct Passport to enable cookie serialization.
Instruct Passport to disable cookie serialization.
Instruct Passport to enable cookie encryption.
Instruct Passport to disable cookie encryption.
Flush all static state.
Details
at line 351
static array
defaultScopes(array|string|null $scopes = null)
Set or get the default scopes.
Given scopes persist for the worker lifetime and affect every request.
at line 367
static array
validScopes(array $scopes)
Return the scopes in the given list that are actually defined scopes for the application.
at line 377
static array
scopeIds()
Get all of the defined scope IDs.
at line 385
static bool
hasScope(string $id)
Determine if the given scope has been defined.
at line 395
static Collection
scopes()
Get all of the scopes defined for the application.
at line 408
static array
scopesFor(array $ids)
Get all of the scopes matching the given IDs.
at line 422
static protected array
configuredScopes()
Get the global scopes and any scopes belonging to the current server.
at line 437
static void
tokensCan(array $scopes)
Define the scopes for the application.
The catalog persists in a static property and affects every request on the worker.
at line 450
static void
tokensCanAccess(array $resources)
Define the resources tokens may access.
The catalog persists in a static property and affects every request on the worker.
at line 460
static bool
hasResource(string $identifier)
Determine whether a resource has been defined.
at line 471
static array
resourcesFor(array $identifiers)
Get the resources matching the given identifiers.
at line 490
static protected array
configuredResources()
Get the global resources and those belonging to the current server.
at line 502
static DateInterval|null
rememberConsentFor(DateTimeInterface|DateInterval|null $duration = null)
Get or set how long user approval is remembered.
A given duration, including null, persists for every subsequent request on the worker.
at line 519
static DateInterval
tokensExpireIn(DateTimeInterface|DateInterval|null $date = null)
Get or set when access tokens expire.
Cached servers retain a given lifetime across requests.
at line 536
static DateInterval
refreshTokensExpireIn(DateTimeInterface|DateInterval|null $date = null)
Get or set when refresh tokens expire.
Cached servers retain a given lifetime across requests.
at line 553
static DateInterval
personalAccessTokensExpireIn(DateTimeInterface|DateInterval|null $date = null)
Get or set when personal access tokens expire.
Cached servers retain a given lifetime across requests.
at line 570
static DateInterval
clientCredentialsTokensExpireIn(DateTimeInterface|DateInterval|null $date = null)
Get or set when client credentials grant tokens expire.
Cached servers retain a given lifetime across requests.
at line 587
static DateInterval
dpopTokensExpireIn(DateTimeInterface|DateInterval|null $date = null)
Get or set the maximum lifetime of proof-bound access tokens.
A given lifetime persists for every subsequent request on the worker.
at line 604
static string
cookie(string|null $cookie = null)
Get or set the name for API token cookies.
A given name persists in a static property and affects every request on the worker.
at line 619
static void
ignoreCsrfToken(bool $ignoreCsrfToken = true)
Indicate that Passport should ignore incoming CSRF tokens.
This policy persists in a static property and affects every request on the worker.
at line 635
static Authenticatable
actingAs(Authenticatable $user, array $scopes = [], string|null $guard = self::DEFAULT_GUARD, Client|null $client = null, array $resources = [])
Set the current user for the application with the given scopes.
This replaces the coroutine's authenticated user and default guard with test state.
at line 672
static Client
actingAsClient(Client $client, array $scopes = [], string|null $guard = self::DEFAULT_GUARD, array $resources = [])
Set the current client for the application with the given scopes.
This installs a resource-server mock and authenticated client in the coroutine's context.
at line 699
static string|null
defaultProvider()
Get the provider for personal access clients without an explicit provider.
at line 709
static void
loadKeysFrom(string $path)
Set the storage location of the encryption keys.
Cached servers retain their loaded keys for the worker lifetime.
at line 718
static string
keyPath(string $file)
Get the location of the encryption keys.
at line 734
static void
useAccessTokenEntity(string $accessTokenEntity)
Set the access token entity class name.
The entity class persists in a static property and affects every issuance on the worker.
at line 747
static void
useConsentModel(string $consentModel)
Set the consent model class name.
The model class persists in a static property and affects every request on the worker.
at line 758
static string
consentModel()
Get the consent model class name.
at line 766
static Consent
consent()
Get a new consent model instance.
at line 778
static void
useAuthCodeModel(string $authCodeModel)
Set the auth code model class name.
The model class persists in a static property and affects every request on the worker.
at line 789
static string
authCodeModel()
Get the auth code model class name.
at line 797
static AuthCode
authCode()
Get a new auth code model instance.
at line 809
static void
usePushedAuthorizationRequestModel(string $pushedAuthorizationRequestModel)
Set the pushed authorization request model class name.
The model class persists for the worker lifetime and affects every request.
at line 820
static string
pushedAuthorizationRequestModel()
Get the pushed authorization request model class name.
at line 828
static PushedAuthorizationRequest
pushedAuthorizationRequest()
Get a new pushed authorization request model instance.
at line 838
static void
useAuthorizationServerResponseType(ResponseTypeInterface|null $authorizationServerResponseType)
Set the default ResponseType that should be used by the authorization server.
Cached servers retain this response prototype for the worker lifetime.
at line 851
static void
useDeviceCodeModel(string $deviceCodeModel)
Set the device code model class name.
The model class persists in a static property and affects every request on the worker.
at line 862
static string
deviceCodeModel()
Get the device code model class name.
at line 870
static DeviceCode
deviceCode()
Get a new device code model instance.
at line 882
static void
useClientModel(string $clientModel)
Set the client model class name.
The model class persists in a static property and affects every request on the worker.
at line 893
static string
clientModel()
Get the client model class name.
at line 901
static Client
client()
Get a new client model instance.
at line 913
static void
useTokenModel(string $tokenModel)
Set the token model class name.
The model class persists in a static property and affects every request on the worker.
at line 924
static string
tokenModel()
Get the token model class name.
at line 932
static Token
token()
Get a new access token model instance.
at line 944
static void
useRefreshTokenModel(string $refreshTokenModel)
Set the refresh token model class name.
The model class persists in a static property and affects every request on the worker.
at line 955
static string
refreshTokenModel()
Get the refresh token model class name.
at line 963
static RefreshToken
refreshToken()
Get a new refresh token model instance.
at line 975
static void
useRefreshTokenFamilyModel(string $refreshTokenFamilyModel)
Set the refresh token family model class name.
The model class persists in a static property and affects every request on the worker.
at line 986
static string
refreshTokenFamilyModel()
Get the refresh token family model class name.
at line 994
static RefreshTokenFamily
refreshTokenFamily()
Get a new refresh token family model instance.
at line 1006
static void
useSigningKeyModel(string $signingKeyModel)
Set the signing key model class name.
The model class persists in a static property and affects every request on the worker.
at line 1017
static string
signingKeyModel()
Get the signing key model class name.
at line 1025
static SigningKey
signingKey()
Get a new signing key model instance.
at line 1037
static void
authenticateAccessTokensUsing(Closure $callback)
Specify an additional access token authentication check.
The callback persists in a static property and runs for every bearer authentication.
at line 1050
static void
authenticateClientsUsing(Closure $callback)
Specify an additional client authentication check.
The callback persists in a static property and runs for every client authentication.
at line 1063
static void
authorizeIntrospectionUsing(Closure $callback)
Authorize resource-server clients to inspect another client's access token.
The callback persists in a static property and affects every introspection request.
at line 1076
static void
resolveResourceMetadataUsing(Closure|null $callback)
Specify the callback resolving protected-resource metadata for authentication challenges.
The callback persists in a static property and affects every authentication challenge on the worker.
at line 1089
static void
inheritGrantAttributes(array $attributes)
Specify grant attributes to carry into issued tokens.
The attribute list persists in a static property and affects every issuance on the worker.
at line 1102
static void
bindCookiesUsing(Closure $callback)
Specify the binding included in and checked against API cookies.
The callback persists in a static property and affects cookies across all requests.
at line 1115
static void
accessTokenClaimsUsing(Closure $callback)
Specify additional claims for issued access tokens.
The callback persists in a static property and affects every issuance on the worker.
at line 1128
static void
issueRefreshTokensUsing(Closure $callback)
Specify whether an access token may receive a refresh token.
The callback persists in a static property and affects every issuance on the worker.
at line 1141
static void
encryptTokensUsing(Closure|null $callback)
Specify the callback that should be invoked to generate encryption keys for encrypting JWT tokens.
The callback supplies random key material that cached servers retain for the worker lifetime.
at line 1150
static string
tokenEncryptionKey(Encrypter $encrypter)
Generate an encryption key for encrypting JWT tokens.
at line 1162
static void
viewNamespace(string $namespace)
Register the views for Passport using conventional names under the given namespace.
The response bindings persist in the worker's container and affect subsequent requests.
at line 1173
static void
viewPrefix(string $prefix)
Register the views for Passport using conventional names under the given prefix.
The response bindings persist in the worker's container and affect subsequent requests.
at line 1190
static void
authorizationView(Closure|string $view)
Specify which view should be used as the authorization view.
The response binding persists in the worker's container and affects subsequent requests.
at line 1204
static void
accountSelectionView(Closure|string $view)
Specify which view should be used to select the approving account.
The response binding persists in the worker's container and affects subsequent requests.
at line 1217
static void
deviceAuthorizationView(Closure|string $view)
Specify which view should be used as the device authorization view.
The response binding persists in the worker's container and affects subsequent requests.
at line 1230
static void
deviceUserCodeView(Closure|string $view)
Specify which view should be used as the device user code view.
The response binding persists in the worker's container and affects subsequent requests.
at line 1241
static void
ignoreRoutes()
Configure Passport to not register its routes.
This changes route registration for the worker's application.
at line 1252
static void
enableDynamicClientRegistration()
Enable the dynamic client registration endpoint.
Call during provider registration, before Passport registers routes for the worker.
at line 1263
static void
withCookieSerialization()
Instruct Passport to enable cookie serialization.
The policy persists in a static property and affects every request on the worker.
at line 1274
static void
withoutCookieSerialization()
Instruct Passport to disable cookie serialization.
The policy persists in a static property and affects every request on the worker.
at line 1285
static void
withCookieEncryption()
Instruct Passport to enable cookie encryption.
The policy persists in a static property and affects every request on the worker.
at line 1296
static void
withoutCookieEncryption()
Instruct Passport to disable cookie encryption.
The policy persists in a static property and affects every request on the worker.
at line 1305
static void
flushState()
Flush all static state.