Tsugi

AccessToken
in package

OAuth 2 client-credentials tokens for LTI Advantage services.

The tool signs a private_key_jwt. Scopes come from the deployment, not from the registration request. One deployment is that deployment's allow list. When the assertion names no deployment and the tool has several, a scope is granted when any of those deployments allows it. The service call still checks the deployment that covers the course.

Table of Contents

Constants

ASSERTION_TYPE  : mixed = 'urn:ietf:params:oauth:client-assertion-type:jw...
EXPIRES  : mixed = 3600
ASSERTION_MAX_SECONDS  : mixed = 300

Methods

audiences()  : array<int, string>
Audiences a tool may put in the client assertion.
grant()  : array{status: int, body: array}
jwksFetchTarget()  : mixed
CURLOPT_RESOLVE entry for a tool JWKS URL, or null when the URL is refused.
verify()  : array{client_id: string, registration_id: int, key_id: int, scopes: array, deployment_id: ?string}|null
assertionTimeOk()  : mixed
audienceMatches()  : mixed
db()  : PDOX
decodeAssertion()  : object|null
decodePlatform()  : object|null
deployments()  : array<int, array{tool_deployment_id: int, deployment_id: string}>
error()  : array{status: int, body: array}
fetchJwks()  : array<string, mixed>|null
isDnsName()  : mixed
jwksAllowLocal()  : mixed
jwksDnsAddresses()  : array<int, string>
jwksFetchDecision()  : array{target: ?string, log_url: string, reason: string, fix: string}
jwksHostAddresses()  : array<int, string>
jwksRefusal()  : array{target: ?string, log_url: string, reason: string, fix: string}
jwksUrlForLog()  : mixed
localJwksFix()  : mixed
logJwksRejection()  : mixed
postString()  : mixed
prefix()  : mixed
registrationByClient()  : array{registration_id: int, key_id: int, client_id: string, jwks_url: string}|null
scopeList()  : array<int, string>
sign()  : mixed

Constants

ASSERTION_TYPE

public mixed ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'

ASSERTION_MAX_SECONDS

private mixed ASSERTION_MAX_SECONDS = 300

Methods

audiences()

Audiences a tool may put in the client assertion.

public static audiences() : array<int, string>

OpenID configuration publishes /lti/token. /ims/token is the same controller.

Return values
array<int, string>

grant()

public static grant(array<string, mixed> $post, array<int, string> $audiences[, array<string, mixed>|null $jwks = null ]) : array{status: int, body: array}
Parameters
$post : array<string, mixed>
$audiences : array<int, string>

token endpoint URLs this assertion may name

$jwks : array<string, mixed>|null = null

tool key set; null fetches lti13_jwks_url

Return values
array{status: int, body: array}

jwksFetchTarget()

CURLOPT_RESOLVE entry for a tool JWKS URL, or null when the URL is refused.

public static jwksFetchTarget(string $url) : mixed

HTTPS only. Loopback, private, and reserved addresses are refused unless $CFG->qa_allow_local_jwks is true. The chosen address is pinned so curl cannot connect somewhere else. When local addresses are allowed, a hosts-file result is used as-is so a name like local.py4e.com stays on this machine.

Parameters
$url : string

verify()

public static verify(string $token) : array{client_id: string, registration_id: int, key_id: int, scopes: array, deployment_id: ?string}|null
Parameters
$token : string
Return values
array{client_id: string, registration_id: int, key_id: int, scopes: array, deployment_id: ?string}|null

assertionTimeOk()

private static assertionTimeOk(object $verified) : mixed
Parameters
$verified : object

audienceMatches()

private static audienceMatches(mixed $aud, array<int, string> $expected) : mixed
Parameters
$aud : mixed
$expected : array<int, string>

decodeAssertion()

private static decodeAssertion(string $jwt, array<string, mixed> $jwks) : object|null
Parameters
$jwt : string
$jwks : array<string, mixed>
Return values
object|null

decodePlatform()

private static decodePlatform(string $token) : object|null
Parameters
$token : string
Return values
object|null

deployments()

private static deployments(int $registrationId, int $keyId) : array<int, array{tool_deployment_id: int, deployment_id: string}>
Parameters
$registrationId : int
$keyId : int
Return values
array<int, array{tool_deployment_id: int, deployment_id: string}>

error()

private static error(int $status, string $error) : array{status: int, body: array}
Parameters
$status : int
$error : string
Return values
array{status: int, body: array}

fetchJwks()

private static fetchJwks(string $url) : array<string, mixed>|null
Parameters
$url : string
Return values
array<string, mixed>|null

isDnsName()

private static isDnsName(string $host) : mixed
Parameters
$host : string

jwksAllowLocal()

private static jwksAllowLocal() : mixed

jwksDnsAddresses()

private static jwksDnsAddresses(string $host) : array<int, string>
Parameters
$host : string
Return values
array<int, string>

jwksFetchDecision()

private static jwksFetchDecision(string $url) : array{target: ?string, log_url: string, reason: string, fix: string}
Parameters
$url : string
Return values
array{target: ?string, log_url: string, reason: string, fix: string}

jwksHostAddresses()

private static jwksHostAddresses(string $host) : array<int, string>
Parameters
$host : string
Return values
array<int, string>

jwksRefusal()

private static jwksRefusal(string $logUrl, string $reason, string $fix) : array{target: ?string, log_url: string, reason: string, fix: string}
Parameters
$logUrl : string
$reason : string
$fix : string
Return values
array{target: ?string, log_url: string, reason: string, fix: string}

jwksUrlForLog()

private static jwksUrlForLog(string $url) : mixed
Parameters
$url : string

localJwksFix()

private static localJwksFix() : mixed

logJwksRejection()

private static logJwksRejection(array{target: ?string, log_url: string, reason: string, fix: string} $decision) : mixed
Parameters
$decision : array{target: ?string, log_url: string, reason: string, fix: string}

postString()

private static postString(array<string, mixed> $post, string $key) : mixed
Parameters
$post : array<string, mixed>
$key : string

registrationByClient()

private static registrationByClient(string $clientId) : array{registration_id: int, key_id: int, client_id: string, jwks_url: string}|null
Parameters
$clientId : string
Return values
array{registration_id: int, key_id: int, client_id: string, jwks_url: string}|null

scopeList()

private static scopeList(string $scope) : array<int, string>
Parameters
$scope : string
Return values
array<int, string>

sign()

private static sign(array{registration_id: int, key_id: int, client_id: string, jwks_url: string} $registration, array<int, string> $scopes, string|null $deploymentId) : mixed
Parameters
$registration : array{registration_id: int, key_id: int, client_id: string, jwks_url: string}
$scopes : array<int, string>
$deploymentId : string|null

        
On this page

Search results