AuthorizationResult
Describes the outcome of an authorization decision.
Use the static factory methods to create instances:
- allow() - Access is granted
- unauthorized() - No valid credentials provided (401)
- forbidden() - Valid credentials but insufficient permissions (403)
- badRequest() - Malformed request (400)
Tags
Table of Contents
Properties
- $allowed : bool
- $attributes : array<string|int, mixed>
- $error : string|null
- $errorDescription : string|null
- $scopes : array<string|int, mixed>|null
- $statusCode : int
Methods
- allow() : self
- Creates a result indicating access is allowed.
- badRequest() : self
- Creates a result indicating a bad request (400).
- forbidden() : self
- Creates a result indicating the request is forbidden (403).
- getAttributes() : array<string, mixed>
- getError() : string|null
- getErrorDescription() : string|null
- getScopes() : array<int, string>|null
- getStatusCode() : int
- isAllowed() : bool
- unauthorized() : self
- Creates a result indicating the request is unauthorized (401).
- __construct() : mixed
Properties
$allowed read-only
private
bool
$allowed
$attributes read-only
private
array<string|int, mixed>
$attributes
$error read-only
private
string|null
$error
$errorDescription read-only
private
string|null
$errorDescription
$scopes read-only
private
array<string|int, mixed>|null
$scopes
$statusCode read-only
private
int
$statusCode
Methods
allow()
Creates a result indicating access is allowed.
public
static allow([array<string, mixed> $attributes = [] ]) : self
Parameters
- $attributes : array<string, mixed> = []
-
Attributes to attach to the request (e.g., user_id, scopes)
Return values
selfbadRequest()
Creates a result indicating a bad request (400).
public
static badRequest([string|null $error = 'invalid_request' ][, string|null $errorDescription = null ]) : self
Use when the Authorization header is malformed.
Parameters
- $error : string|null = 'invalid_request'
-
OAuth error code (defaults to "invalid_request")
- $errorDescription : string|null = null
-
Human-readable error description
Return values
selfforbidden()
Creates a result indicating the request is forbidden (403).
public
static forbidden([string|null $error = 'insufficient_scope' ][, string|null $errorDescription = null ][, array<int, string>|null $scopes = null ]) : self
Use when the token is valid but lacks required permissions/scopes.
Parameters
- $error : string|null = 'insufficient_scope'
-
OAuth error code (defaults to "insufficient_scope")
- $errorDescription : string|null = null
-
Human-readable error description
- $scopes : array<int, string>|null = null
-
Required scopes to include in challenge
Return values
selfgetAttributes()
public
getAttributes() : array<string, mixed>
Return values
array<string, mixed>getError()
public
getError() : string|null
Return values
string|nullgetErrorDescription()
public
getErrorDescription() : string|null
Return values
string|nullgetScopes()
public
getScopes() : array<int, string>|null
Return values
array<int, string>|nullgetStatusCode()
public
getStatusCode() : int
Return values
intisAllowed()
public
isAllowed() : bool
Return values
boolunauthorized()
Creates a result indicating the request is unauthorized (401).
public
static unauthorized([string|null $error = null ][, string|null $errorDescription = null ][, array<int, string>|null $scopes = null ]) : self
Use when no valid credentials are provided or the token is invalid.
Parameters
- $error : string|null = null
-
OAuth error code (e.g., "invalid_token")
- $errorDescription : string|null = null
-
Human-readable error description
- $scopes : array<int, string>|null = null
-
Required scopes to include in challenge
Return values
self__construct()
private
__construct(bool $allowed, int $statusCode, string|null $error, string|null $errorDescription, array<int, string>|null $scopes, array<string, mixed> $attributes) : mixed
Parameters
- $allowed : bool
- $statusCode : int
- $error : string|null
- $errorDescription : string|null
- $scopes : array<int, string>|null
-
Scopes to include in WWW-Authenticate challenge
- $attributes : array<string, mixed>
-
Attributes to attach to the request on success