Skip to content

Commit dc3543f

Browse files
committed
feature #30 Rename events and remove psr7 doc (mtarld)
This PR was merged into the 0.1-dev branch. Discussion ---------- Rename events and remove psr7 doc Commits ------- 24e646e Rename events and remove psr7 doc
2 parents 534714c + 24e646e commit dc3543f

File tree

7 files changed

+14
-45
lines changed

7 files changed

+14
-45
lines changed

docs/controlling-token-scopes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Controlling token scopes
22

3-
It's possible to alter issued access token's scopes by subscribing to the `league.oauth2_server.scope_resolve` event.
3+
It's possible to alter issued access token's scopes by subscribing to the `league.oauth2_server.event.scope_resolve` event.
44

55
## Example
66

@@ -30,5 +30,5 @@ final class ScopeResolveListener
3030
```yaml
3131
App\EventListener\ScopeResolveListener:
3232
tags:
33-
- { name: kernel.event_listener, event: league.oauth2_server.scope_resolve, method: onScopeResolve }
33+
- { name: kernel.event_listener, event: league.oauth2_server.event.scope_resolve, method: onScopeResolve }
3434
```

docs/index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ For implementation into Symfony projects, please see [bundle documentation](docs
1717

1818
## Installation
1919

20-
1. Require the bundle and a PSR 7/17 implementation with Composer:
20+
1. Require the bundle with Composer:
2121

2222
```sh
23-
composer require league/oauth2-server-bundle nyholm/psr7
23+
composer require league/oauth2-server-bundle
2424
```
2525

2626
If your project is managed using [Symfony Flex](https://github.com/symfony/flex), the rest of the steps are not required. Just follow the post-installation instructions instead! :tada:
2727

28-
> **NOTE:** This bundle requires a PSR 7/17 implementation to operate. We recommend that you use [nyholm/psr7](https://github.com/Nyholm/psr7). Check out this [document](docs/psr-implementation-switching.md) if you wish to use a different implementation.
29-
3028
1. Create the bundle configuration file under `config/packages/league_oauth2_server.yaml`. Here is a reference configuration file:
3129

3230
```yaml

docs/psr-implementation-switching.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/OAuth2Events.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ final class OAuth2Events
1212
*
1313
* You should set a valid user here if applicable.
1414
*/
15-
public const USER_RESOLVE = 'league.oauth2_server.user_resolve';
15+
public const USER_RESOLVE = 'league.oauth2_server.event.user_resolve';
1616

1717
/**
1818
* The SCOPE_RESOLVE event occurs right before the user obtains their
1919
* valid access token.
2020
*
2121
* You could alter the access token's scope here.
2222
*/
23-
public const SCOPE_RESOLVE = 'league.oauth2_server.scope_resolve';
23+
public const SCOPE_RESOLVE = 'league.oauth2_server.event.scope_resolve';
2424

2525
/**
2626
* The AUTHORIZATION_REQUEST_RESOLVE event occurs right before the system
@@ -29,5 +29,5 @@ final class OAuth2Events
2929
* You could approve or deny the authorization request, or set the uri where
3030
* must be redirected to resolve the authorization request.
3131
*/
32-
public const AUTHORIZATION_REQUEST_RESOLVE = 'league.oauth2_server.authorization_request_resolve';
32+
public const AUTHORIZATION_REQUEST_RESOLVE = 'league.oauth2_server.event.authorization_request_resolve';
3333
}

src/Resources/config/services.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use League\Bundle\OAuth2ServerBundle\Manager\InMemory\ScopeManager;
3131
use League\Bundle\OAuth2ServerBundle\Manager\RefreshTokenManagerInterface;
3232
use League\Bundle\OAuth2ServerBundle\Manager\ScopeManagerInterface;
33+
use League\Bundle\OAuth2ServerBundle\OAuth2Events;
3334
use League\Bundle\OAuth2ServerBundle\Security\Authentication\Provider\OAuth2Provider;
3435
use League\Bundle\OAuth2ServerBundle\Security\Authentication\Token\OAuth2TokenFactory;
3536
use League\Bundle\OAuth2ServerBundle\Security\EntryPoint\OAuth2EntryPoint;
@@ -227,7 +228,7 @@ function service(string $id): ReferenceConfigurator
227228
service(Security::class),
228229
])
229230
->tag('kernel.event_listener', [
230-
'event' => 'league.oauth2_server.authorization_request_resolve',
231+
'event' => OAuth2Events::AUTHORIZATION_REQUEST_RESOLVE,
231232
'method' => 'onAuthorizationRequest',
232233
'priority' => 1024,
233234
])

tests/Acceptance/TokenEndpointTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface;
1111
use League\Bundle\OAuth2ServerBundle\Manager\RefreshTokenManagerInterface;
1212
use League\Bundle\OAuth2ServerBundle\Manager\ScopeManagerInterface;
13+
use League\Bundle\OAuth2ServerBundle\OAuth2Events;
1314
use League\Bundle\OAuth2ServerBundle\Tests\Fixtures\FixtureFactory;
1415
use League\Bundle\OAuth2ServerBundle\Tests\TestHelper;
1516

@@ -54,7 +55,7 @@ public function testSuccessfulPasswordRequest(): void
5455
$this->client
5556
->getContainer()
5657
->get('event_dispatcher')
57-
->addListener('league.oauth2_server.user_resolve', static function (UserResolveEvent $event): void {
58+
->addListener(OAuth2Events::USER_RESOLVE, static function (UserResolveEvent $event): void {
5859
$event->setUser(FixtureFactory::createUser());
5960
});
6061

tests/Integration/AuthorizationServerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use League\Bundle\OAuth2ServerBundle\Event\UserResolveEvent;
88
use League\Bundle\OAuth2ServerBundle\Model\AccessToken;
99
use League\Bundle\OAuth2ServerBundle\Model\RefreshToken;
10+
use League\Bundle\OAuth2ServerBundle\OAuth2Events;
1011
use League\Bundle\OAuth2ServerBundle\Tests\Fixtures\FixtureFactory;
1112
use League\Bundle\OAuth2ServerBundle\Tests\TestHelper;
1213

@@ -265,7 +266,7 @@ public function testValidClientCredentialsGrantWithRequestedScope(): void
265266

266267
public function testValidPasswordGrant(): void
267268
{
268-
$this->eventDispatcher->addListener('league.oauth2_server.user_resolve', static function (UserResolveEvent $event): void {
269+
$this->eventDispatcher->addListener(OAuth2Events::USER_RESOLVE, static function (UserResolveEvent $event): void {
269270
$event->setUser(FixtureFactory::createUser());
270271
});
271272

@@ -294,7 +295,7 @@ public function testValidPasswordGrant(): void
294295

295296
public function testInvalidCredentialsPasswordGrant(): void
296297
{
297-
$this->eventDispatcher->addListener('league.oauth2_server.user_resolve', static function (UserResolveEvent $event): void {
298+
$this->eventDispatcher->addListener(OAuth2Events::USER_RESOLVE, static function (UserResolveEvent $event): void {
298299
$event->setUser(null);
299300
});
300301

0 commit comments

Comments
 (0)