Skip to content

Commit

Permalink
Fixed doc with last updates
Browse files Browse the repository at this point in the history
  • Loading branch information
yann-eugone committed Mar 6, 2021
1 parent 7684cd3 commit e2d4a05
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ Develop your features, the bundle is taking care of the technical implementation
Documentation
-------------

- [Installation](Resources/doc/1-installation.md)
- [Configuration](Resources/doc/2-configuration.md)
- [Usage](Resources/doc/3-usage.md)
- [Archive command](Resources/doc/4-archive-command.md)
- [Events](Resources/doc/5-events.md)
- [Installation](doc/1-installation.md)
- [Configuration](doc/2-configuration.md)
- [Usage](doc/3-usage.md)
- [Archive command](doc/4-archive-command.md)
- [Events](doc/5-events.md)


MIT License
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"require": {
"php": "^7.1.3",
"ext-openssl": "*",
"symfony/framework-bundle": "^4.4|^5.0",
"symfony/framework-bundle": "^4.4",
"doctrine/orm": "^2.7",
"doctrine/doctrine-bundle": "^2.0",
"yokai/dependency-injection": "^1.0"
Expand Down
2 changes: 1 addition & 1 deletion doc/1-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ return [

---

« [README](../../README.md)[Configuration](2-configuration.md) »
« [README](../README.md)[Configuration](2-configuration.md) »
4 changes: 2 additions & 2 deletions doc/2-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ yokai_security_token:
Each token can have following options :
- `generator` : a service id that implements [`Yokai\SecurityTokenBundle\Generator\TokenGeneratorInterface`](../../Generator/TokenGeneratorInterface.php)
- `generator` : a service id that implements [`Yokai\SecurityTokenBundle\Generator\TokenGeneratorInterface`](../src/Generator/TokenGeneratorInterface.php)
- `duration` : a valid [`DateTime::modify`](https://php.net/manual/datetime.modify.php) argument that represent the validity duration for tokens of this type
- `usages` : an integer that represent the number of allowed usages for tokens of this type (`0` means unlimited)
- `keep` : a valid [`DateTime::modify`](https://php.net/manual/datetime.modify.php) argument that represent the keep duration for tokens of this type
- `unique` : a boolean that indicates whether or not the token must be unique per user

Default values fallback to :

- `generator` : [`yokai_security_token.open_ssl_token_generator`](../../Generator/OpenSslTokenGenerator.php)
- `generator` : [`yokai_security_token.open_ssl_token_generator`](../src/Generator/OpenSslTokenGenerator.php)
- `duration` : `+2 days`
- `usages` : `1`
- `keep` : `+1 month`
Expand Down
5 changes: 3 additions & 2 deletions doc/3-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ use App\Entity\User;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Yokai\SecurityTokenBundle\Exception as TokenExceptions;
use Yokai\SecurityTokenBundle\Manager\TokenManagerInterface;

class SecurityController extends Controller
class SecurityController extends AbstractController
{
/** @var TokenManagerInterface */
private $tokenManager;
/** @var ManagerRegistry */
private $doctrine;

public function __construct(TokenManagerInterface $tokenManager, ManagerRegistry $doctrine)
{
$this->tokenManager = $tokenManager;
Expand Down
6 changes: 4 additions & 2 deletions doc/4-archive-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ bin/console yokai:security-token:archive
The command is using the archivist service to perform the operation.

> **Note :** The default implementation of the service is
> [`Yokai\SecurityTokenBundle\Archive\DeleteArchivist`](../../Archive/DeleteArchivist.php).
> [`Yokai\SecurityTokenBundle\Archive\DeleteArchivist`](../src/Archive/DeleteArchivist.php).
> This implementation just delete every outdated tokens, based on the `keepUntil` property.

Expand All @@ -30,9 +30,11 @@ use Yokai\SecurityTokenBundle\Archive\ArchivistInterface;

class AppArchivist implements ArchivistInterface
{
public function archive($purpose = null, \DateTime $before = null)
public function archive(string $purpose = null): int
{
// whatever you can imagine

return 0; // how much tokens were archived
}
}
```
Expand Down
24 changes: 11 additions & 13 deletions doc/5-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@ Events

The bundle is dispatching event at some points of the token life time.

> **Note :** Event names are stored in constants located in [TokenEvents](../../TokenEvents.php).

### When creating a token

Whenever you call `Yokai\SecurityTokenBundle\Manager\TokenManagerInterface::create` :

- `TokenEvents::CREATE_TOKEN` : [CreateTokenEvent](../../Event/CreateTokenEvent.php)
- `TokenEvents::TOKEN_CREATED` : [TokenCreatedEvent](../../Event/TokenCreatedEvent.php)
- **Before** the token is created : [CreateTokenEvent](../src/Event/CreateTokenEvent.php)
- **After** the token is created : [TokenCreatedEvent](../src/Event/TokenCreatedEvent.php)


### When retrieving a token

Whenever you call `Yokai\SecurityTokenBundle\Manager\TokenManagerInterface::get` :

- `TokenEvents::TOKEN_NOT_FOUND` : [TokenNotFoundEvent](../../Event/TokenNotFoundEvent.php)
- `TokenEvents::TOKEN_EXPIRED` : [TokenExpiredEvent](../../Event/TokenExpiredEvent.php)
- `TokenEvents::TOKEN_ALREADY_CONSUMED` : [TokenAlreadyConsumedEvent](../../Event/TokenAlreadyConsumedEvent.php)
- `TokenEvents::TOKEN_RETRIEVED` : [TokenRetrievedEvent](../../Event/TokenRetrievedEvent.php)
- When token is **not found** : [TokenNotFoundEvent](../src/Event/TokenNotFoundEvent.php)
- When token is **expired** : [TokenExpiredEvent](../src/Event/TokenExpiredEvent.php)
- When token is **already consumed** : [TokenAlreadyConsumedEvent](../src/Event/TokenAlreadyConsumedEvent.php)
- When token is **valid** : [TokenRetrievedEvent](../src/Event/TokenRetrievedEvent.php)


### When consuming a token

Whenever you call `Yokai\SecurityTokenBundle\Manager\TokenManagerInterface::consume` :

- `TokenEvents::CONSUME_TOKEN` : [ConsumeTokenEvent](../../Event/ConsumeTokenEvent.php)
- `TokenEvents::TOKEN_CONSUMED` : [TokenConsumedEvent](../../Event/TokenConsumedEvent.php)
- `TokenEvents::TOKEN_TOTALLY_CONSUMED` : [TokenTotallyConsumedEvent](../../Event/TokenTotallyConsumedEvent.php)
- **Before** token is consumed : [ConsumeTokenEvent](../src/Event/ConsumeTokenEvent.php)
- **After** token is consumed : [TokenConsumedEvent](../src/Event/TokenConsumedEvent.php)
- **After** token is totally consumed (not usable again) : [TokenTotallyConsumedEvent](../src/Event/TokenTotallyConsumedEvent.php)


### Subscribe to events
Expand Down Expand Up @@ -58,7 +56,7 @@ class LogSecurityTokenErrors implements EventSubscriberInterface
$this->logger = $logger;
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
SecurityTokenEvents\TokenNotFoundEvent::class => 'onTokenNotFound',
Expand Down Expand Up @@ -96,4 +94,4 @@ class LogSecurityTokenErrors implements EventSubscriberInterface

---

« [Archive command](4-archive-command.md)[README](../../README.md) »
« [Archive command](4-archive-command.md)[README](../README.md) »

0 comments on commit e2d4a05

Please sign in to comment.