Skip to content

Commit d2ae925

Browse files
committed
pass kid on service and deep linking responses
1 parent 87ec58d commit d2ae925

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/lti/LTI_Deep_Link.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function get_response_jwt($resources) {
2727
"https://purl.imsglobal.org/spec/lti-dl/claim/content_items" => array_map(function($resource) { return $resource->to_array(); }, $resources),
2828
"https://purl.imsglobal.org/spec/lti-dl/claim/data" => $this->deep_link_settings['data'],
2929
];
30-
return JWT::encode($message_jwt, $this->registration->get_tool_private_key(), 'RS256');
30+
return JWT::encode($message_jwt, $this->registration->get_tool_private_key(), 'RS256', $this->registration->get_kid());
3131
}
3232

3333
public function output_response_form($resources) {

src/lti/LTI_Registration.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,23 @@ public function set_tool_private_key($tool_private_key) {
7171
return $this;
7272
}
7373

74+
public function get_kid() {
75+
hash('sha256', trim($this->issuer . $this->client_id));
76+
}
77+
7478
public function get_public_jwk() {
7579
$key = new RSA();
7680
$key->setPrivateKey($this->get_tool_private_key());
7781
$key->setPublicKey();
78-
if ( !$key->publicExponent ){
82+
if ( !$key->publicExponent ) {
7983
return [];
8084
}
81-
$kid = hash('sha256', trim($this->issuer . $this->client_id));
8285
$components = array(
8386
'kty' => 'RSA',
8487
'alg' => 'RS256',
8588
'e' => JWT::urlsafeB64Encode($key->publicExponent->toBytes()),
8689
'n' => JWT::urlsafeB64Encode($key->modulus->toBytes()),
87-
'kid' => $kid,
90+
'kid' => $this->get_kid(),
8891
);
8992
if ($key->exponent != $key->publicExponent) {
9093
$components = array_merge($components, array(

src/lti/LTI_Service_Connector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function get_access_token($scopes) {
3434
];
3535

3636
// Sign the JWT with our private key (given by the platform on registration)
37-
$jwt = JWT::encode($jwt_claim, $this->registration->get_tool_private_key(), 'RS256');
37+
$jwt = JWT::encode($jwt_claim, $this->registration->get_tool_private_key(), 'RS256', $this->registration->get_kid());
3838

3939
// Build auth token request headers
4040
$auth_request = [

0 commit comments

Comments
 (0)