Skip to content
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

Added simple explaination for custom scopes #312

Open
wants to merge 2 commits into
base: v3.x
Choose a base branch
from
Open
Changes from all commits
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
35 changes: 35 additions & 0 deletions docs/controlling-token-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,38 @@ App\EventListener\ScopeResolveListener:
tags:
- { name: kernel.event_listener, event: trikoder.oauth2.scope_resolve, method: onScopeResolve }
```

## Work with refresh token
The scopes created in this way will not be recognized by the library when trying to login using the `refresh_token` grant method.
In order to append new scopes, you need to override the service `Trikoder\Bundle\OAuth2Bundle\Manager\ScopeManagerInterface`.
Here is an example:
```yaml
# services.yaml
Trikoder\Bundle\OAuth2Bundle\Manager\ScopeManagerInterface:
alias: Path\To\Custom\Manager
```
in the manager you can implement the business logic needed to validate the tokens you issued in the scope resolve listener
```php
<?php

namespace App\Guards;


use Trikoder\Bundle\OAuth2Bundle\Manager\ScopeManagerInterface;
use Trikoder\Bundle\OAuth2Bundle\Model\Scope;

class CustomScopeManager implements ScopeManagerInterface
{

public function find(string $identifier): ?Scope
{
// your logic here, if created return a new scope with the name
return null;
}

public function save(Scope $scope): void
{
// your logic here
}
}
```