Skip to content

Commit

Permalink
Dynamic registration support
Browse files Browse the repository at this point in the history
Added support for the LTI 1.3 dynamic registration process available in Moodle 3.10+
Avoid use of $_REQUEST
  • Loading branch information
spvickers committed Nov 26, 2020
1 parent 91e61a7 commit e0c2a63
Show file tree
Hide file tree
Showing 7 changed files with 431 additions and 13 deletions.
7 changes: 7 additions & 0 deletions src/Jwt/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
interface ClientInterface
{

/**
* Return an array of supported signature algorithms.
*
* @return string[] Array of algorithm names
*/
public static function getSupportedAlgorithms();

/**
* Check if a JWT is defined.
*
Expand Down
14 changes: 13 additions & 1 deletion src/Jwt/FirebaseClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@
class FirebaseClient implements ClientInterface
{

const SUPPORTED_ALGORITHMS = array('RS256', 'RS384', 'RS512');

private $jwtString = null;
private $jwtHeaders = null;
private $jwtPayload = null;
private static $lastHeaders = null;
private static $lastPayload = null;

/**
* Return an array of supported signature algorithms.
*
* @return string[] Array of algorithm names
*/
public static function getSupportedAlgorithms()
{
return self::SUPPORTED_ALGORITHMS;
}

/**
* Check if a JWT is defined.
*
Expand Down Expand Up @@ -219,7 +231,7 @@ public function verify($publicKey, $jku = null)
$retry = false;
do {
try {
JWT::decode($this->jwtString, $publicKey, array('RS256', 'RS384', 'RS512'));
JWT::decode($this->jwtString, $publicKey, self::SUPPORTED_ALGORITHMS);
$ok = true;
} catch (\Exception $e) {
Util::logError($e->getMessage());
Expand Down
14 changes: 13 additions & 1 deletion src/Jwt/SpomkyLabsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,23 @@
class SpomkyLabsClient implements ClientInterface
{

const SUPPORTED_ALGORITHMS = array('RS256', 'RS384', 'RS512');

private $jwe = null;
private $jwt = null;
private static $lastHeaders = null;
private static $lastPayload = null;

/**
* Return an array of supported signature algorithms.
*
* @return string[] Array of algorithm names
*/
public static function getSupportedAlgorithms()
{
return self::SUPPORTED_ALGORITHMS;
}

/**
* Check if a JWT is defined.
*
Expand Down Expand Up @@ -377,7 +389,7 @@ public static function getPublicKey($privateKey)
/**
* Get the public JWKS from a key in PEM or JWK format.
*
* @param string $Key Private or public key in PEM or JWK format
* @param string $key Private or public key in PEM or JWK format
* @param string $signatureMethod Signature method
* @param string $kid Key ID (optional)
*
Expand Down
12 changes: 12 additions & 0 deletions src/Jwt/WebTokenClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@
class WebTokenClient implements ClientInterface
{

const SUPPORTED_ALGORITHMS = array('RS256', 'RS384', 'RS512');

private $jwe = null;
private $jwt = null;
private $claims = array();
private static $lastHeaders = null;
private static $lastPayload = null;

/**
* Return an array of supported signature algorithms.
*
* @return string[] Array of algorithm names
*/
public static function getSupportedAlgorithms()
{
return self::SUPPORTED_ALGORITHMS;
}

/**
* Check if a JWT is defined.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Platform
/**
* The tool proxy.
*
* @var object|null $toolPrixy
* @var object|null $toolProxy
*/
public $toolProxy = null;

Expand Down
Loading

0 comments on commit e0c2a63

Please sign in to comment.