Replace custom aud and ely-scopes JWT claims with its public analogues

This commit is contained in:
ErickSkrauch
2019-12-13 13:55:09 +03:00
parent 274d56aa40
commit a8e20a9775
8 changed files with 104 additions and 33 deletions

View File

@@ -31,19 +31,16 @@ class TokenReader {
}
public function getClientId(): ?string {
$aud = $this->token->getClaim('aud', false);
if ($aud === false) {
return null;
}
if (mb_strpos((string)$aud, TokensFactory::AUD_CLIENT_PREFIX) !== 0) {
return null;
}
return mb_substr($aud, mb_strlen(TokensFactory::AUD_CLIENT_PREFIX));
return $this->token->getClaim('client_id', false) ?: null;
}
public function getScopes(): ?array {
$scopes = $this->token->getClaim('scope', false);
if ($scopes !== false) {
return explode(' ', $scopes);
}
// Handle legacy tokens, which used "ely-scopes" claim and was delimited with comma
$scopes = $this->token->getClaim('ely-scopes', false);
if ($scopes === false) {
return null;