Dhananjay
Dhananjay

Reputation: 105

syntax for token_provider in symfony remember_me

I'm building remember_me functionality in symfony. Instead of tokens being stored in cookies I want to store them in database So, I'm trying to use an option called token_provider but there is not much information detailed on Symfony.com.

I am new to Symfony, can any one share the syntax of "token_provider" in security.yml->firewalls->remember_me?

any help will be appreciated.

Changes I have done

  1. Created a custom service which extends Symfony\Bridge\Doctrine\Security\RememberMe\DoctrineTokenProvider and passed the db connection object from the constructor

    class CustomTokenService extends DoctrineTokenService { public function __construct(EntityManagerInterface $em){ parent::__construct($em->getConnection()); } }

  2. Registered this service in app/config/services.yml

Upvotes: 0

Views: 363

Answers (1)

Dhananjay
Dhananjay

Reputation: 105

custom service in services.yml:
token_service: alias:{App}\Bundle\Services\Utilities\CustomTokenService
public: true

In Security.yml:
remember_me:
secret: '%kernel.secret%'
lifetime: 604800 # 1 week in seconds
path: /
domain: ~
remember_me_parameter: _stay_signedin
token_provider: token_service

Upvotes: 0

Related Questions