rest - Symfony2.8 API + Login Form -
i have website uses symfony2.8; working on mobile app use same project backend need support token based authentication regular login forms. resources i've found talk api authentication not api(token based) , form. has ideas how accomplish this?
i using fosuserbundle if matters.
you can using custom authenticators each case.
symfony 2.8 introduced guard, makes it's relatively easy create custom authenticators.
basically create 2 custom authenticators , means creating 2 services.
- formloginauthenticator -> app.form_login_authenticator
- apitokenauthenticator -> app.api_token_authenticator
once these services created, have register authenticators
in app/config/security.yml
security: ... main: anonymous: ~ knpu_guard: authenticators: - app.form_login_authenticator - app.api_token_authenticator entry_point: app.form_login_authenticator
obviously it's upto implement services, symfony docs provide decent starting point start .
check these links same :
- how create custom authentication system guard
- how use multiple guard authenticators
- https://knpuniversity.com/screencast/guard ( provides working example + tutorial )
Comments
Post a Comment