Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400]

A Helper for LTI Dynamic Registration.

Copyright: 2020 Claude Vervoort (Cengage), Carlos Costa, Adrian Hutchinson (Macgraw Hill)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 449 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: registration_helper  - X-Ref

This class exposes functions for LTI Dynamic Registration.

get()   X-Ref
Get an instance of this helper

return: object

get_parameter(array $payload, string $key, bool $required)   X-Ref
Function used to validate parameters.

This function is needed because the payload contains nested
objects, and optional_param() does not support arrays of arrays.

return: mixed
param: array $payload that may contain the parameter key
param: string $key the key of the value to be looked for in the payload
param: bool $required if required, not finding a value will raise a registration_exception

registration_to_config(array $registrationpayload, string $clientid)   X-Ref
Transforms an LTI 1.3 Registration to a Moodle LTI Config.

return: object the Moodle LTI config.
param: array $registrationpayload the registration data received from the tool.
param: string $clientid the clientid to be issued for that tool.

add_previous_key_claim(array &$lticonfig, string $key, string $secret)   X-Ref
Adds to the config the LTI 1.1 key and sign it with the 1.1 secret.

param: array $lticonfig reference to lticonfig to which to add the 1.1 OAuth info.
param: string $key - LTI 1.1 OAuth Key
param: string $secret - LTI 1.1 OAuth Secret

config_to_registration(object $config, int $typeid, object $type = null)   X-Ref
Transforms a moodle LTI 1.3 Config to an OAuth/LTI Client Registration.

return: array the Client Registration as an associative array.
param: object $config Moodle LTI Config.
param: int $typeid which is the LTI deployment id.
param: object $type tool instance in case the tool already exists.

validate_registration_token(string $registrationtokenjwt)   X-Ref
Validates the registration token is properly signed and not used yet.
Return the client id to use for this registration.

return: array with 2 keys: clientid for the registration, type but only if it's an update
param: string $registrationtokenjwt registration token

lti_get_service_scopes()   X-Ref
Initializes an array with the scopes for services supported by the LTI module

return: array List of scopes

new_clientid()   X-Ref
Generates a new client id string.

return: string generated client id

sign(string $key, string $salt, string $secret)   X-Ref
Base64 encoded signature for LTI 1.1 migration.

return: string base64encoded hash
param: string $key LTI 1.1 key
param: string $salt Salt value
param: string $secret LTI 1.1 secret

get_tool_proxy(int $proxyid)   X-Ref
Returns a tool proxy

return: mixed Tool Proxy details
param: int $proxyid