Skip to content

Commit 9bfb699

Browse files
authored
Merge pull request #1181 from datapp/bugfix/scope-named-0-considered-to-be-invalid
Default Scope does not work as expected
2 parents 0d57b70 + 936e229 commit 9bfb699

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515
### Fixed
1616
- 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)
1717
- Added type validation for redirect uri, client ID, client secret, scopes, auth code, state, username, and password inputs (PR #1210)
18+
- Allow scope "0" to be used. Previously this was removed from a request because it failed an `empty()` check (PR #1181)
1819

1920
## [8.2.4] - released 2020-12-10
2021
### Fixed

src/Grant/AbstractGrant.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ public function validateScopes($scopes, $redirectUri = null)
325325
private function convertScopesQueryStringToArray(string $scopes)
326326
{
327327
return \array_filter(\explode(self::SCOPE_DELIMITER_STRING, \trim($scopes)), function ($scope) {
328-
return !empty($scope);
328+
return $scope !== '';
329329
});
330330
}
331331

tests/Grant/AbstractGrantTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,13 @@ public function testValidateScopes()
521521
{
522522
$scope = new ScopeEntity();
523523
$scopeRepositoryMock = $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock();
524-
$scopeRepositoryMock->method('getScopeEntityByIdentifier')->willReturn($scope);
524+
$scopeRepositoryMock->expects($this->exactly(3))->method('getScopeEntityByIdentifier')->willReturn($scope);
525525

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

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

533533
public function testValidateScopesBadScope()

0 commit comments

Comments
 (0)