class AuthServerDiscovery

Traits

Properties

protected int $maxOAuthResponseSize from  InteractsWithOAuthEndpoints
static protected Closure|null $hostResolver

Methods

oAuthRequest()

Prepare a buffered OAuth request without following redirects.

resolveOAuthDestination(PendingRequest $request, string $url)

Validate and pin an OAuth endpoint within the prepared request's limits.

bool
isLocalhost(string $host)

Determine whether the normalized host names a local development endpoint.

string
normalizedHost(string $host)

Normalize the host consistently with destination validation.

static void
resolveHostsUsing(Closure|null $callback)

Resolve OAuth destination hostnames with the given callback instead of DNS.

static array|null
resolvedHostAddresses(string $host)

Get the addresses the resolveHostsUsing() callback supplies for a hostname.

discover(string $resourceUrl, string|null $resourceMetadataUrl = null)

Discover and validate the resource's authorization server.

void
requireAdvertised(string $resourceUrl, string $resourceMetadataUrl, array $headers = [])

Require caller-supplied metadata to be advertised by the resource.

pin(PendingRequest $request)

Validate each request hop against the OAuth destination policy and pin it to the vetted addresses.

probe(string $resourceUrl, array $headers)

Probe the resource for its unauthenticated authorization challenge.

array
fetchResourceMetadata(string $metadataUrl, bool $explicit = false)

Fetch optional or explicitly requested protected resource metadata.

void
requireResourceMatches(array $resourceMetadata, string $resourceUrl)

Verify that metadata belongs to the requested resource.

string|null
issuerFrom(array $resourceMetadata)

Get the resource's first advertised authorization server.

fetchMetadata(string $issuer)

Fetch authorization metadata from the issuer's supported discovery paths.

array
metadataUrls(string $issuer)

Get the OAuth and OpenID discovery URLs for an issuer.

string
wellKnown(string $url, string $type)

Build a well-known metadata URL for the resource path and query.

string
origin(string $url)

Get the URL's origin.

void
requireSecure(string $url)

Require HTTPS outside local development endpoints.

void
requireFetchable(string $url, string $resourceUrl)

Validate a metadata endpoint before fetching it.

void
requireNotInternal(string $url, string $resourceUrl)

Prevent remote resources from directing authorization to local endpoints.

bool
isInternalHost(string $host)

Determine whether a host is local or a non-public address literal.

string
originFromParts(array $parts)

Build an origin from parsed URL components.

array
parse(string $url)

Parse the URL components required for discovery.

static void
flushState()

Flush all static state.

Details

protected PendingRequest oAuthRequest()

Prepare a buffered OAuth request without following redirects.

Return Value

PendingRequest

protected ResolvedDestination resolveOAuthDestination(PendingRequest $request, string $url)

Validate and pin an OAuth endpoint within the prepared request's limits.

Parameters

PendingRequest $request
string $url

Return Value

ResolvedDestination

protected bool isLocalhost(string $host)

Determine whether the normalized host names a local development endpoint.

Parameters

string $host

Return Value

bool

protected string normalizedHost(string $host)

Normalize the host consistently with destination validation.

Parameters

string $host

Return Value

string

at line 41
static void resolveHostsUsing(Closure|null $callback)

Resolve OAuth destination hostnames with the given callback instead of DNS.

The callback persists in a static property for the worker lifetime and supplies the addresses for every OAuth request.

Parameters

Closure|null $callback

Return Value

void

at line 54
static array|null resolvedHostAddresses(string $host)

internal  
 

Get the addresses the resolveHostsUsing() callback supplies for a hostname.

Parameters

string $host

Return Value

array|null

at line 62
DiscoveryResult discover(string $resourceUrl, string|null $resourceMetadataUrl = null)

Discover and validate the resource's authorization server.

Parameters

string $resourceUrl
string|null $resourceMetadataUrl

Return Value

DiscoveryResult

at line 119
void requireAdvertised(string $resourceUrl, string $resourceMetadataUrl, array $headers = [])

Require caller-supplied metadata to be advertised by the resource.

Parameters

string $resourceUrl
string $resourceMetadataUrl
array $headers

Return Value

void

at line 145
PendingRequest pin(PendingRequest $request)

Validate each request hop against the OAuth destination policy and pin it to the vetted addresses.

Parameters

PendingRequest $request

Return Value

PendingRequest

at line 168
protected Response probe(string $resourceUrl, array $headers)

Probe the resource for its unauthenticated authorization challenge.

Parameters

string $resourceUrl
array $headers

Return Value

Response

at line 199
protected array fetchResourceMetadata(string $metadataUrl, bool $explicit = false)

Fetch optional or explicitly requested protected resource metadata.

Parameters

string $metadataUrl
bool $explicit

Return Value

array

at line 229
protected void requireResourceMatches(array $resourceMetadata, string $resourceUrl)

Verify that metadata belongs to the requested resource.

Parameters

array $resourceMetadata
string $resourceUrl

Return Value

void

at line 250
protected string|null issuerFrom(array $resourceMetadata)

Get the resource's first advertised authorization server.

Parameters

array $resourceMetadata

Return Value

string|null

at line 264
protected AuthServerMetadata fetchMetadata(string $issuer)

Fetch authorization metadata from the issuer's supported discovery paths.

Parameters

string $issuer

Return Value

AuthServerMetadata

at line 288
protected array metadataUrls(string $issuer)

Get the OAuth and OpenID discovery URLs for an issuer.

Parameters

string $issuer

Return Value

array

at line 313
protected string wellKnown(string $url, string $type)

Build a well-known metadata URL for the resource path and query.

Parameters

string $url
string $type

Return Value

string

at line 330
protected string origin(string $url)

Get the URL's origin.

Parameters

string $url

Return Value

string

at line 338
protected void requireSecure(string $url)

Require HTTPS outside local development endpoints.

Parameters

string $url

Return Value

void

at line 359
void requireFetchable(string $url, string $resourceUrl)

Validate a metadata endpoint before fetching it.

Parameters

string $url
string $resourceUrl

Return Value

void

at line 368
protected void requireNotInternal(string $url, string $resourceUrl)

Prevent remote resources from directing authorization to local endpoints.

Parameters

string $url
string $resourceUrl

Return Value

void

at line 397
protected bool isInternalHost(string $host)

Determine whether a host is local or a non-public address literal.

Parameters

string $host

Return Value

bool

at line 415
protected string originFromParts(array $parts)

Build an origin from parsed URL components.

Parameters

array $parts

Return Value

string

at line 425
protected array parse(string $url)

Parse the URL components required for discovery.

Parameters

string $url

Return Value

array

at line 440
static void flushState()

Flush all static state.

Return Value

void