Tsugi

DynamicRegistration
in package

LTI Advantage dynamic registration (LMS OpenID config + client registration).

Used by Settings (instructor) and admin/key/auto.php (super user). Caller must already have sent $OUTPUT->header() / bodyStart().

Table of Contents

Methods

allowsOpenIdEndpoint()  : bool
https is required for an OpenID endpoint.
deploymentIdFromResponse()  : string|null
Deployment id from a dynamic-registration response.
messagesForPlatform()  : array<int, array<string, mixed>>
Keep message types and placements the platform advertised.
openidConfigurationMatchesIssuer()  : bool
The configuration URL must be the issuer, or a path concatenated onto it.
redactSecrets()  : string
Hide a registration token or bearer token in text shown to the browser.
registrationFailureReport()  : string
Text for a failed registration POST. The body is the LMS response.
run()  : string
comparisonSegment()  : string
Decode percent-encoded unreserved characters. Leave a reserved escape, such as %3B, in the path so it does not compare equal to ";".
deploymentIdValue()  : string|null
isSakai()  : bool
Sakai's product family is sakai or sakailms.org.
isStoreTarget()  : bool
The store picker, not a placement-specific query on that URL.
messagesSupported()  : array<string, array<string, true>|null>|null
Null when the platform did not publish messages_supported.
omitRedundantMessages()  : array<int, array<string, mixed>>
Drop an exact copy, and a placement-less message whose target is already offered by a placed message of the same type. A placement-less message with its own target, such as Tsugi Plus, stays.
pathUsesDotSegment()  : bool
placementAdvertised()  : bool
A short name matches an advertised URL whose path ends in that name.
placementLeaf()  : string
platformFamily()  : string
prettyJson()  : mixed
Indent JSON for display. Other text is left as it was retrieved.
resolvedPath()  : string|false
Path after . and .. segments are removed, including a once-decoded segment such as %2e%2e. Interior empty segments are kept. A trailing slash is not. False when the path climbs above the root or a segment hides a slash.
sakaiLaunch()  : array<string, mixed>
One launch. Placements and Canvas extensions stay off this message.
sakaiMessages()  : array<int, array<string, mixed>>
One launch, then privacy. Plus is the resource link. Otherwise the launch is the store deep link. Privacy stays second so Sakai keeps the launch URL.
urlPort()  : int

Methods

allowsOpenIdEndpoint()

https is required for an OpenID endpoint.

public static allowsOpenIdEndpoint(string $url) : bool

LTI Dynamic Registration 1.0 section 2.1.1 requires an https issuer. http is allowed only for localhost, 127.0.0.1, or ::1, so a local LMS can still be registered.

Parameters
$url : string
Return values
bool

deploymentIdFromResponse()

Deployment id from a dynamic-registration response.

public static deploymentIdFromResponse(object|null $response) : string|null

The tool configuration is checked first. Canvas returns the id beside that object, as deployment_id on the response.

Parameters
$response : object|null
Return values
string|null

messagesForPlatform()

Keep message types and placements the platform advertised.

public static messagesForPlatform(array<int, array<string, mixed>> $messages, object|null $platform) : array<int, array<string, mixed>>

A platform that does not publish messages_supported is left unchanged.

Parameters
$messages : array<int, array<string, mixed>>
$platform : object|null

OpenID configuration

Return values
array<int, array<string, mixed>>

openidConfigurationMatchesIssuer()

The configuration URL must be the issuer, or a path concatenated onto it.

public static openidConfigurationMatchesIssuer(mixed $configuration_url, mixed $issuer) : bool

LTI Dynamic Registration 1.0 section 3.4. Query parameters are allowed. A fragment is not. The host must match exactly, so a subdomain of the issuer is rejected. Section 3.5.1 requires this check before registration, to guard against impersonation. Dot segments are removed first. A fetch resolves /tenant/../outside to /outside, and that path is what the prefix is compared to. An empty segment stays, so /tenant//blue is not /tenant/blue. A percent-encoded reserved character stays encoded. RFC 3986 section 6.2.2.2 does not treat %3B as the same character as ";". https://www.imsglobal.org/spec/lti-dr/v1p0

Parameters
$configuration_url : mixed
$issuer : mixed
Return values
bool

redactSecrets()

Hide a registration token or bearer token in text shown to the browser.

public static redactSecrets(mixed $text[, mixed $token = null ]) : string

The known token is removed first, before any caller truncates the text. A token shorter than 8 characters is left alone so a tiny value cannot wipe ordinary words out of the error.

Parameters
$text : mixed
$token : mixed = null
Return values
string

registrationFailureReport()

Text for a failed registration POST. The body is the LMS response.

public static registrationFailureReport(mixed $status, mixed $body, mixed $headers[, mixed $curl_error = false ][, mixed $token = null ]) : string

Secrets are removed from the cURL error, headers, and body before any truncation, so a cut cannot leave a token behind without its marker.

Parameters
$status : mixed
$body : mixed
$headers : mixed
$curl_error : mixed = false
$token : mixed = null

Registration token to remove wherever the LMS echoed it

Return values
string

run()

public static run(int|string|null $user_id, mixed $tsugi_key, mixed $unlock_code, mixed $openid_configuration, mixed $registration_token) : string
Parameters
$user_id : int|string|null

0 is the admin/super-user path

$tsugi_key : mixed
$unlock_code : mixed
$openid_configuration : mixed
$registration_token : mixed
Return values
string —

Empty string after HTML is printed

comparisonSegment()

Decode percent-encoded unreserved characters. Leave a reserved escape, such as %3B, in the path so it does not compare equal to ";".

private static comparisonSegment(string $segment) : string
Parameters
$segment : string
Return values
string

deploymentIdValue()

private static deploymentIdValue(mixed $value) : string|null
Parameters
$value : mixed
Return values
string|null

isSakai()

Sakai's product family is sakai or sakailms.org.

private static isSakai(object|null $platform) : bool
Parameters
$platform : object|null
Return values
bool

isStoreTarget()

The store picker, not a placement-specific query on that URL.

private static isStoreTarget(string $target) : bool
Parameters
$target : string
Return values
bool

messagesSupported()

Null when the platform did not publish messages_supported.

private static messagesSupported(object|null $platform) : array<string, array<string, true>|null>|null
Parameters
$platform : object|null
Return values
array<string, array<string, true>|null>|null

omitRedundantMessages()

Drop an exact copy, and a placement-less message whose target is already offered by a placed message of the same type. A placement-less message with its own target, such as Tsugi Plus, stays.

private static omitRedundantMessages(array<int, array<string, mixed>> $messages, array<string, array<string, true>|null> $rules) : array<int, array<string, mixed>>
Parameters
$messages : array<int, array<string, mixed>>
$rules : array<string, array<string, true>|null>
Return values
array<int, array<string, mixed>>

pathUsesDotSegment()

private static pathUsesDotSegment(string|null|false $path) : bool
Parameters
$path : string|null|false
Return values
bool

placementAdvertised()

A short name matches an advertised URL whose path ends in that name.

private static placementAdvertised(string $placement, array<string, true> $advertised) : bool

The name we send is left as it is.

Parameters
$placement : string
$advertised : array<string, true>
Return values
bool

placementLeaf()

private static placementLeaf(string $name) : string
Parameters
$name : string
Return values
string

platformFamily()

private static platformFamily(object|null $platform) : string
Parameters
$platform : object|null
Return values
string

prettyJson()

Indent JSON for display. Other text is left as it was retrieved.

private static prettyJson(mixed $raw) : mixed
Parameters
$raw : mixed

resolvedPath()

Path after . and .. segments are removed, including a once-decoded segment such as %2e%2e. Interior empty segments are kept. A trailing slash is not. False when the path climbs above the root or a segment hides a slash.

private static resolvedPath(string|null $path) : string|false
Parameters
$path : string|null
Return values
string|false

sakaiLaunch()

One launch. Placements and Canvas extensions stay off this message.

private static sakaiLaunch(array<string, mixed> $message) : array<string, mixed>
Parameters
$message : array<string, mixed>
Return values
array<string, mixed>

sakaiMessages()

One launch, then privacy. Plus is the resource link. Otherwise the launch is the store deep link. Privacy stays second so Sakai keeps the launch URL.

private static sakaiMessages(array<int, array<string, mixed>> $messages) : array<int, array<string, mixed>>
Parameters
$messages : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

urlPort()

private static urlPort(array<string, mixed> $parts, string $scheme) : int
Parameters
$parts : array<string, mixed>
$scheme : string
Return values
int

        
On this page

Search results