Skip to content

Commit

Permalink
Merge pull request #1181 from datapp/bugfix/scope-named-0-considered-…
Browse files Browse the repository at this point in the history
…to-be-invalid

Default Scope does not work as expected
  • Loading branch information
Sephster authored May 31, 2021
2 parents 0d57b70 + 936e229 commit 9bfb699
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- The server will now only recognise and handle an authorization header if the value of the header is non-empty. This is to circumvent issues where some common frameworks set this header even if no value is present (PR #1170)
- Added type validation for redirect uri, client ID, client secret, scopes, auth code, state, username, and password inputs (PR #1210)
- Allow scope "0" to be used. Previously this was removed from a request because it failed an `empty()` check (PR #1181)

## [8.2.4] - released 2020-12-10
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/Grant/AbstractGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public function validateScopes($scopes, $redirectUri = null)
private function convertScopesQueryStringToArray(string $scopes)
{
return \array_filter(\explode(self::SCOPE_DELIMITER_STRING, \trim($scopes)), function ($scope) {
return !empty($scope);
return $scope !== '';
});
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Grant/AbstractGrantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,13 @@ public function testValidateScopes()
{
$scope = new ScopeEntity();
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
$scopeRepositoryMock->method('getScopeEntityByIdentifier')->willReturn($scope);
$scopeRepositoryMock->expects($this->exactly(3))->method('getScopeEntityByIdentifier')->willReturn($scope);

/** @var AbstractGrant $grantMock */
$grantMock = $this->getMockForAbstractClass(AbstractGrant::class);
$grantMock->setScopeRepository($scopeRepositoryMock);

$this->assertEquals([$scope], $grantMock->validateScopes('basic '));
$this->assertEquals([$scope, $scope, $scope], $grantMock->validateScopes('basic test 0 '));
}

public function testValidateScopesBadScope()
Expand Down

0 comments on commit 9bfb699

Please sign in to comment.