Skip to content

Commit

Permalink
PODA-7: code review
Browse files Browse the repository at this point in the history
  • Loading branch information
cophaso committed Jun 23, 2021
1 parent 9abe86e commit 63c4e77
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/LtiServiceConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public function __construct(ILtiRegistration $registration, ICache $cache, Clien

public function getAccessToken(array $scopes)
{
// Don't fetch the same key more than once.
sort($scopes);

// Build up JWT to exchange for an auth token
$clientId = $this->registration->getClientId();

Expand Down Expand Up @@ -67,7 +64,6 @@ public function getAccessToken(array $scopes)

// Get Access
$response = $this->client->post($url, [
'timeout' => 10,
'form_params' => $authRequest,
]);

Expand All @@ -86,18 +82,16 @@ public function makeServiceRequest(array $scopes, $method, $url, $body = null, $
'Accept' => $accept,
];

switch ($method) {
switch (strtoupper($method)) {
case 'POST':
$headers = array_merge($headers, ['Content-Type' => $contentType]);
$response = $this->client->request($method, $url, [
'headers' => $headers,
'json' => $body,
'timeout' => 60,
]);
break;
default:
$response = $this->client->request($method, $url, [
'timeout' => 60,
'headers' => $headers,
]);
break;
Expand All @@ -114,6 +108,9 @@ public function makeServiceRequest(array $scopes, $method, $url, $body = null, $

private function getAccessTokenCacheKey(array $scopes)
{
// Don't fetch the same key more than once.
sort($scopes);

$scopeKey = md5(implode('|', $scopes));

return $this->registration->getIssuer().$this->registration->getClientId().$scopeKey;
Expand Down

0 comments on commit 63c4e77

Please sign in to comment.