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.

$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

static array
defaultScopes(array|string|null $scopes = null)

Set or get the default scopes.

static array
validScopes(array $scopes)

Return the scopes in the given list that are actually defined scopes for the application.

static array
scopeIds()

Get all of the defined scope IDs.

static bool
hasScope(string $id)

Determine if the given scope has been defined.

static Collection
scopes()

Get all of the scopes defined for the application.

static array
scopesFor(array $ids)

Get all of the scopes matching the given IDs.

static array
configuredScopes()

Get the global scopes and any scopes belonging to the current server.

static void
tokensCan(array $scopes)

Define the scopes for the application.

static void
tokensCanAccess(array $resources)

Define the resources tokens may access.

static bool
hasResource(string $identifier)

Determine whether a resource has been defined.

static array
resourcesFor(array $identifiers)

Get the resources matching the given identifiers.

static array
configuredResources()

Get the global resources and those belonging to the current server.

static DateInterval|null
rememberConsentFor(DateTimeInterface|DateInterval|null $duration = null)

Get or set how long user approval is remembered.

static DateInterval
tokensExpireIn(DateTimeInterface|DateInterval|null $date = null)

Get or set when access tokens expire.

static DateInterval
refreshTokensExpireIn(DateTimeInterface|DateInterval|null $date = null)

Get or set when refresh tokens expire.

static DateInterval
personalAccessTokensExpireIn(DateTimeInterface|DateInterval|null $date = null)

Get or set when personal access tokens expire.

static DateInterval
clientCredentialsTokensExpireIn(DateTimeInterface|DateInterval|null $date = null)

Get or set when client credentials grant tokens expire.

static DateInterval
dpopTokensExpireIn(DateTimeInterface|DateInterval|null $date = null)

Get or set the maximum lifetime of proof-bound access tokens.

static string
cookie(string|null $cookie = null)

Get or set the name for API token cookies.

static void
ignoreCsrfToken(bool $ignoreCsrfToken = true)

Indicate that Passport should ignore incoming CSRF tokens.

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.

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.

static string|null
defaultProvider()

Get the provider for personal access clients without an explicit provider.

static void
loadKeysFrom(string $path)

Set the storage location of the encryption keys.

static string
keyPath(string $file)

Get the location of the encryption keys.

static void
useAccessTokenEntity(string $accessTokenEntity)

Set the access token entity class name.

static void
useConsentModel(string $consentModel)

Set the consent model class name.

static string
consentModel()

Get the consent model class name.

static Consent
consent()

Get a new consent model instance.

static void
useAuthCodeModel(string $authCodeModel)

Set the auth code model class name.

static string
authCodeModel()

Get the auth code model class name.

static AuthCode
authCode()

Get a new auth code model instance.

static void
usePushedAuthorizationRequestModel(string $pushedAuthorizationRequestModel)

Set the pushed authorization request model class name.

static string
pushedAuthorizationRequestModel()

Get the pushed authorization request model class name.

pushedAuthorizationRequest()

Get a new pushed authorization request model instance.

static void
useAuthorizationServerResponseType(ResponseTypeInterface|null $authorizationServerResponseType)

Set the default ResponseType that should be used by the authorization server.

static void
useDeviceCodeModel(string $deviceCodeModel)

Set the device code model class name.

static string
deviceCodeModel()

Get the device code model class name.

static DeviceCode
deviceCode()

Get a new device code model instance.

static void
useClientModel(string $clientModel)

Set the client model class name.

static string
clientModel()

Get the client model class name.

static Client
client()

Get a new client model instance.

static void
useTokenModel(string $tokenModel)

Set the token model class name.

static string
tokenModel()

Get the token model class name.

static Token
token()

Get a new access token model instance.

static void
useRefreshTokenModel(string $refreshTokenModel)

Set the refresh token model class name.

static string
refreshTokenModel()

Get the refresh token model class name.

static RefreshToken
refreshToken()

Get a new refresh token model instance.

static void
useRefreshTokenFamilyModel(string $refreshTokenFamilyModel)

Set the refresh token family model class name.

static string
refreshTokenFamilyModel()

Get the refresh token family model class name.

refreshTokenFamily()

Get a new refresh token family model instance.

static void
useSigningKeyModel(string $signingKeyModel)

Set the signing key model class name.

static string
signingKeyModel()

Get the signing key model class name.

static SigningKey
signingKey()

Get a new signing key model instance.

static void
authenticateAccessTokensUsing(Closure $callback)

Specify an additional access token authentication check.

static void
authenticateClientsUsing(Closure $callback)

Specify an additional client authentication check.

static void
authorizeIntrospectionUsing(Closure $callback)

Authorize resource-server clients to inspect another client's access token.

static void
resolveResourceMetadataUsing(Closure|null $callback)

Specify the callback resolving protected-resource metadata for authentication challenges.

static void
inheritGrantAttributes(array $attributes)

Specify grant attributes to carry into issued tokens.

static void
bindCookiesUsing(Closure $callback)

Specify the binding included in and checked against API cookies.

static void
accessTokenClaimsUsing(Closure $callback)

Specify additional claims for issued access tokens.

static void
issueRefreshTokensUsing(Closure $callback)

Specify whether an access token may receive a refresh token.

static void
encryptTokensUsing(Closure|null $callback)

Specify the callback that should be invoked to generate encryption keys for encrypting JWT tokens.

static string
tokenEncryptionKey(Encrypter $encrypter)

Generate an encryption key for encrypting JWT tokens.

static void
viewNamespace(string $namespace)

Register the views for Passport using conventional names under the given namespace.

static void
viewPrefix(string $prefix)

Register the views for Passport using conventional names under the given prefix.

static void
authorizationView(Closure|string $view)

Specify which view should be used as the authorization view.

static void
accountSelectionView(Closure|string $view)

Specify which view should be used to select the approving account.

static void
deviceAuthorizationView(Closure|string $view)

Specify which view should be used as the device authorization view.

static void
deviceUserCodeView(Closure|string $view)

Specify which view should be used as the device user code view.

static void
ignoreRoutes()

Configure Passport to not register its routes.

static void
enableDynamicClientRegistration()

Enable the dynamic client registration endpoint.

static void
withCookieSerialization()

Instruct Passport to enable cookie serialization.

static void
withoutCookieSerialization()

Instruct Passport to disable cookie serialization.

static void
withCookieEncryption()

Instruct Passport to enable cookie encryption.

static void
withoutCookieEncryption()

Instruct Passport to disable cookie encryption.

static void
flushState()

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.

Parameters

array|string|null $scopes

Return Value

array

at line 367
static array validScopes(array $scopes)

Return the scopes in the given list that are actually defined scopes for the application.

Parameters

array $scopes

Return Value

array

at line 377
static array scopeIds()

Get all of the defined scope IDs.

Return Value

array

at line 385
static bool hasScope(string $id)

Determine if the given scope has been defined.

Parameters

string $id

Return Value

bool

at line 395
static Collection scopes()

Get all of the scopes defined for the application.

Return Value

Collection

at line 408
static array scopesFor(array $ids)

Get all of the scopes matching the given IDs.

Parameters

array $ids

Return Value

array

at line 422
static protected array configuredScopes()

Get the global scopes and any scopes belonging to the current server.

Return Value

array

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.

Parameters

array $scopes

Return Value

void

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.

Parameters

array $resources

Return Value

void

at line 460
static bool hasResource(string $identifier)

Determine whether a resource has been defined.

Parameters

string $identifier

Return Value

bool

at line 471
static array resourcesFor(array $identifiers)

Get the resources matching the given identifiers.

Parameters

array $identifiers

Return Value

array

at line 490
static protected array configuredResources()

Get the global resources and those belonging to the current server.

Return Value

array

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.

Parameters

DateTimeInterface|DateInterval|null $duration

Return Value

DateInterval|null

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.

Parameters

DateTimeInterface|DateInterval|null $date

Return Value

DateInterval

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.

Parameters

DateTimeInterface|DateInterval|null $date

Return Value

DateInterval

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.

Parameters

DateTimeInterface|DateInterval|null $date

Return Value

DateInterval

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.

Parameters

DateTimeInterface|DateInterval|null $date

Return Value

DateInterval

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.

Parameters

DateTimeInterface|DateInterval|null $date

Return Value

DateInterval

Get or set the name for API token cookies.

A given name persists in a static property and affects every request on the worker.

Parameters

string|null $cookie

Return Value

string

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.

Parameters

bool $ignoreCsrfToken

Return Value

void

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.

Parameters

Authenticatable $user
array $scopes
string|null $guard
Client|null $client
array $resources

Return Value

Authenticatable

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.

Parameters

Client $client
array $scopes
string|null $guard
array $resources

Return Value

Client

at line 699
static string|null defaultProvider()

Get the provider for personal access clients without an explicit provider.

Return Value

string|null

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.

Parameters

string $path

Return Value

void

at line 718
static string keyPath(string $file)

Get the location of the encryption keys.

Parameters

string $file

Return Value

string

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.

Parameters

string $accessTokenEntity

Return Value

void

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.

Parameters

string $consentModel

Return Value

void

at line 758
static string consentModel()

Get the consent model class name.

Return Value

string

Get a new consent model instance.

Return Value

Consent

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.

Parameters

string $authCodeModel

Return Value

void

at line 789
static string authCodeModel()

Get the auth code model class name.

Return Value

string

at line 797
static AuthCode authCode()

Get a new auth code model instance.

Return Value

AuthCode

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.

Parameters

string $pushedAuthorizationRequestModel

Return Value

void

at line 820
static string pushedAuthorizationRequestModel()

Get the pushed authorization request model class name.

Return Value

string

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.

Parameters

ResponseTypeInterface|null $authorizationServerResponseType

Return Value

void

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.

Parameters

string $deviceCodeModel

Return Value

void

at line 862
static string deviceCodeModel()

Get the device code model class name.

Return Value

string

at line 870
static DeviceCode deviceCode()

Get a new device code model instance.

Return Value

DeviceCode

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.

Parameters

string $clientModel

Return Value

void

at line 893
static string clientModel()

Get the client model class name.

Return Value

string

at line 901
static Client client()

Get a new client model instance.

Return Value

Client

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.

Parameters

string $tokenModel

Return Value

void

at line 924
static string tokenModel()

Get the token model class name.

Return Value

string

at line 932
static Token token()

Get a new access token model instance.

Return Value

Token

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.

Parameters

string $refreshTokenModel

Return Value

void

at line 955
static string refreshTokenModel()

Get the refresh token model class name.

Return Value

string

at line 963
static RefreshToken refreshToken()

Get a new refresh token model instance.

Return Value

RefreshToken

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.

Parameters

string $refreshTokenFamilyModel

Return Value

void

at line 986
static string refreshTokenFamilyModel()

Get the refresh token family model class name.

Return Value

string

at line 994
static RefreshTokenFamily refreshTokenFamily()

Get a new refresh token family model instance.

Return Value

RefreshTokenFamily

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.

Parameters

string $signingKeyModel

Return Value

void

at line 1017
static string signingKeyModel()

Get the signing key model class name.

Return Value

string

at line 1025
static SigningKey signingKey()

Get a new signing key model instance.

Return Value

SigningKey

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.

Parameters

Closure $callback

Return Value

void

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.

Parameters

Closure $callback

Return Value

void

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.

Parameters

Closure $callback

Return Value

void

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.

Parameters

Closure|null $callback

Return Value

void

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.

Parameters

array $attributes

Return Value

void

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.

Parameters

Closure $callback

Return Value

void

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.

Parameters

Closure $callback

Return Value

void

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.

Parameters

Closure $callback

Return Value

void

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.

Parameters

Closure|null $callback

Return Value

void

at line 1150
static string tokenEncryptionKey(Encrypter $encrypter)

Generate an encryption key for encrypting JWT tokens.

Parameters

Encrypter $encrypter

Return Value

string

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.

Parameters

string $namespace

Return Value

void

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.

Parameters

string $prefix

Return Value

void

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.

Parameters

Closure|string $view

Return Value

void

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.

Parameters

Closure|string $view

Return Value

void

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.

Parameters

Closure|string $view

Return Value

void

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.

Parameters

Closure|string $view

Return Value

void

at line 1241
static void ignoreRoutes()

Configure Passport to not register its routes.

This changes route registration for the worker's application.

Return Value

void

at line 1252
static void enableDynamicClientRegistration()

Enable the dynamic client registration endpoint.

Call during provider registration, before Passport registers routes for the worker.

Return Value

void

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.

Return Value

void

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.

Return Value

void

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.

Return Value

void

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.

Return Value

void

at line 1305
static void flushState()

Flush all static state.

Return Value

void