Skip to content

Commit

Permalink
fix/getScopes (#17)
Browse files Browse the repository at this point in the history
* ensure that returned scopes are always array

* Fix styling

Co-authored-by: herpaderpaldent <[email protected]>
  • Loading branch information
herpaderpaldent and herpaderpaldent authored Sep 21, 2022
1 parent f1118d4 commit abb6973
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/DataTransferObjects/EsiAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public function getScopes() : array

$jwt_payload = JWT::urlsafeB64Decode($jwt_payload_base64_encoded);

return data_get(json_decode($jwt_payload), 'scp', []);
$scopes = data_get(json_decode($jwt_payload), 'scp', []);

return is_array($scopes) ? $scopes : [$scopes];
}
}
4 changes: 0 additions & 4 deletions src/EsiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,11 @@ public function setAuthentication(EsiAuthentication $authentication): void
*/
public function invoke(string $method, string $uri_original, array $uri_data = [])
{

// Enrich the uri
$uri = $this->buildDataUri($uri_original, $uri_data);

// First check if access requirements are met
if (! $this->getAccessChecker()->can($method, $uri_original)) {

// Log the deny.
$this->logger->warning('Access denied to ' . $uri . ' due to ' .
'missing scopes.');
Expand Down Expand Up @@ -153,7 +151,6 @@ private function getConfiguration(): Configuration

private function buildDataUri(string $uri, array $data): Uri
{

// Create a query string for the URI. We automatically
// include the datasource value from the configuration.
$query_params = array_merge([
Expand All @@ -177,7 +174,6 @@ private function buildDataUri(string $uri, array $data): Uri

private function mapDataToUri(string $uri, array $data): string
{

// Extract fields in curly braces. If there are fields,
// replace the data with those in the URI
if (preg_match_all('/{+(.*?)}/', $uri, $matches)) {
Expand Down
1 change: 0 additions & 1 deletion src/Log/RotatingFileLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class RotatingFileLogger implements LogInterface
*/
public function __construct()
{

// Get the configuration values
$configuration = Configuration::getInstance();

Expand Down
1 change: 0 additions & 1 deletion src/Services/UpdateRefreshTokenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

class UpdateRefreshTokenService
{

/**
* Tranquility endpoint for retrieving user info.
*/
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/Services/RefreshTokenServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

/** @runInSeparateProcess */
it('updates access token with refresh token', function () {

// create a private key for signing the JWT Token
$privKey = openssl_pkey_new(['digest_alg' => 'sha256',
'private_key_bits' => 1024,
Expand Down Expand Up @@ -72,7 +71,6 @@
});

it('throws RequestFailedException if an exception occurs', function () {

// create the client mock and responses from said client
$mock = new \GuzzleHttp\Handler\MockHandler([
new Response(400, [], 'Error'),
Expand Down

0 comments on commit abb6973

Please sign in to comment.