Skip to content

Commit

Permalink
Merge pull request #1112 from Sephster/pass-authcode-to-finalize-scopes
Browse files Browse the repository at this point in the history
Pass authcode to finalize scopes
  • Loading branch information
Sephster authored Apr 18, 2020
2 parents 21d1f9a + ebeb0f4 commit 4e0b715
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed (v9)
- Authorization Request objects are now created through the factory method, `createAuthorizationRequest()` (PR #1111)
- Changed parameters for `finalizeScopes()` to allow a reference to an auth code ID (PR #1112)

### Changed
- If an error is encountered when running `preg_match()` to validate an RSA key, the server will now throw a RuntimeException (PR #1047)
Expand Down
3 changes: 2 additions & 1 deletion src/Grant/AuthCodeGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public function respondToAccessTokenRequest(
$this->validateScopes($authCodePayload->scopes),
$this->getIdentifier(),
$client,
$authCodePayload->user_id
$authCodePayload->user_id,
$authCodePayload->auth_code_id
);
} catch (LogicException $e) {
throw OAuthServerException::invalidRequest('code', 'Cannot decrypt the authorization code', $e);
Expand Down
7 changes: 5 additions & 2 deletions src/Grant/PasswordGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ public function respondToAccessTokenRequest(
$scopes = $this->validateScopes($this->getRequestParameter('scope', $request, $this->defaultScope));
$user = $this->validateUser($request, $client);

// Finalize the requested scopes
$finalizedScopes = $this->scopeRepository->finalizeScopes($scopes, $this->getIdentifier(), $client, $user->getIdentifier());
$finalizedScopes = $this->scopeRepository->finalizeScopes(
$scopes,
$this->getIdentifier(),
$client,
$user->getIdentifier());

// Issue and persist new access token
$accessToken = $this->issueAccessToken($accessTokenTTL, $client, $user->getIdentifier(), $finalizedScopes);
Expand Down
4 changes: 3 additions & 1 deletion src/Repositories/ScopeRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public function getScopeEntityByIdentifier($identifier);
* @param string $grantType
* @param ClientEntityInterface $clientEntity
* @param null|string $userIdentifier
* @param null|string $authCodeId
*
* @return ScopeEntityInterface[]
*/
public function finalizeScopes(
array $scopes,
$grantType,
ClientEntityInterface $clientEntity,
$userIdentifier = null
$userIdentifier = null,
$authCodeId = null
);
}

0 comments on commit 4e0b715

Please sign in to comment.