Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring JWT verification algorithms #341

Open
pulsejet opened this issue Oct 19, 2022 · 0 comments
Open

Allow configuring JWT verification algorithms #341

pulsejet opened this issue Oct 19, 2022 · 0 comments

Comments

@pulsejet
Copy link

Currently all of the following are allowed, but they may not be secure enough.

$payload = implode('.', $parts);
switch ($header->alg) {
case 'RS256':
case 'PS256':
case 'PS512':
case 'RS384':
case 'RS512':
$hashtype = 'sha' . substr($header->alg, 2);
$signatureType = $header->alg === 'PS256' || $header->alg === 'PS512' ? 'PSS' : '';
if (isset($header->jwk)) {
$jwk = $header->jwk;
$this->verifyJWKHeader($jwk);
} else {
$jwks = json_decode($this->fetchURL($this->getProviderConfigValue('jwks_uri')));
if ($jwks === NULL) {
throw new OpenIDConnectClientException('Error decoding JSON from jwks_uri');
}
$jwk = $this->getKeyForHeader($jwks->keys, $header);
}
$verified = $this->verifyRSAJWTsignature($hashtype,
$jwk,
$payload, $signature, $signatureType);
break;
case 'HS256':
case 'HS512':
case 'HS384':
$hashtype = 'SHA' . substr($header->alg, 2);
$verified = $this->verifyHMACJWTsignature($hashtype, $this->getClientSecret(), $payload, $signature);
break;
default:
throw new OpenIDConnectClientException('No support for signature type: ' . $header->alg);
}
return $verified;

From pulsejet/nextcloud-oidc-login#126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant