/jwt-authenticator-bundle

JWT Authenticator Bundle

Primary LanguagePHPMIT LicenseMIT

jwt-authenticator-bundle

JWT Authenticator Bundle

Installation

This component can be installed with the Composer dependency manager.

  1. Install Composer

  2. Install the component as a dependency of your project

     composer require free2er/jwt-authenticator-bundle
    
  3. Enable the bundle

<?php

// config/bundles.php
return [
    // ...
    Free2er\Jwt\JwtAuthenticatorBundle::class => ['all' => true],
    // ...
];
  1. Configure the path to the public key
# config/packages/jwt_authenticator.yaml
jwt_authenticator:
    key: file://%kernel.project_dir%/path/to/public.key
  1. Configure the firewall
# config/packages/security.yaml
security:
    providers:
        jwt:
            id: Free2er\Jwt\Service\UserProvider
    firewalls:
        # ...
        main:
            pattern: ^/api
            stateless: true
            provider: jwt
            guard:
                authenticators:
                    - Free2er\Jwt\Service\Authenticator
        # ...
  1. Done!