Skip to content

youshido-php/TokenAuthenticatorBundle

Folders and files

NameName
Last commit message
Last commit date
Feb 12, 2017
Nov 26, 2020
Feb 16, 2018
Feb 12, 2017
Feb 12, 2017
Apr 18, 2019
Apr 18, 2019
Feb 3, 2016
Feb 3, 2016
Sep 5, 2016
Feb 6, 2018
Nov 26, 2020

Repository files navigation

TokenAuthenticationBundle

This bundle allow you to use a token authentication mechanism similar to OAuth but much more simplified.

Installation

First, enable bundle in your AppKernel by adding it to the registerBundles method:

...
            new Youshido\TokenAuthenticationBundle\TokenAuthenticationBundle(),

Then create provider and firewall under app/config/security.yml (if you don't have encoder yet – might as well add it here):

security:
    providers:
        api_user_provider:
            id: token_user_provider

    encoders:
        AppBundle\Entity\User: md5

    firewalls:
        api_firewall:
            pattern: ^/.*
            stateless: true
            simple_preauth:
                authenticator: token_authenticator
            provider: api_user_provider
            anonymous: ~

Now add your model class name to the service declaration app/config/config.yml:

token_authentication:
    user_model: "AppBundle\\Entity\\User"