Skip to content

Support for JWT Bearer #79

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

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions lib/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class OAuth2
*
* @see http://tools.ietf.org/html/draft-ietf-oauth-v2-20#section-4.5
*/
const GRANT_TYPE_REGEXP = '#^(authorization_code|token|password|client_credentials|refresh_token|https?://.*)$#';
const GRANT_TYPE_REGEXP = '#^(authorization_code|token|password|client_credentials|refresh_token|https?://.+|urn:.+)$#';

/**
* @}
Expand Down Expand Up @@ -823,12 +823,8 @@ public function grantAccessToken(Request $request = null)
$stored = $this->grantAccessTokenRefreshToken($client, $input);
break;
default:
if (filter_var($input["grant_type"], FILTER_VALIDATE_URL)) {
// returns: true || array('scope' => scope)
$stored = $this->grantAccessTokenExtension($client, $inputData, $authHeaders);
} else {
throw new OAuth2ServerException(self::HTTP_BAD_REQUEST, self::ERROR_INVALID_REQUEST, 'Invalid grant_type parameter or parameter missing');
}
// returns: true || array('scope' => scope) || array('data' => data, 'scope' => scope)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to change this check to keep the uri verification:

if (0 === strpos($input["grant_type"], 'urn') || filter_var($input["grant_type"], FILTER_VALIDATE_URL)) {

$stored = $this->grantAccessTokenExtension($client, $inputData, $authHeaders);
}

if (!is_array($stored)) {
Expand Down Expand Up @@ -1001,8 +997,7 @@ protected function grantAccessTokenExtension(IOAuth2Client $client, array $input
if (!($this->storage instanceof IOAuth2GrantExtension)) {
throw new OAuth2ServerException(self::HTTP_BAD_REQUEST, self::ERROR_UNSUPPORTED_GRANT_TYPE);
}
$uri = filter_var($inputData["grant_type"], FILTER_VALIDATE_URL);
$stored = $this->storage->checkGrantExtension($client, $uri, $inputData, $authHeaders);
$stored = $this->storage->checkGrantExtension($client, $inputData["grant_type"], $inputData, $authHeaders);

if ($stored === false) {
throw new OAuth2ServerException(self::HTTP_BAD_REQUEST, self::ERROR_INVALID_GRANT);
Expand Down