Currently my project (Frontend and Backend both Symfony2) uses the HWIOAuthBundle for authentication via Google, etc.
Since I want to separate the frontend (frontend AngularJS) from the backend. Communication will rely on JSON data (so REST in general).
I'm facing the problem how to achieve this with the HWIOAuthBundle. The symfony documentation says something about stateless: true
, but then HWIOAuthBundle doesn't work.
In addition: In the future I'm want to implement FOSUserBundle for new user (who doesn't authenticate via OAuth).
My questions: 1. How can I achieve stateless authentication with HWIOAuthBundle 2. How should I achieve stateless authentication in general (HWIOAuthBundle and FOSUserBundle). The symfony documentation says stateless authentication is done by always sending username / password in each request. I think authentication via token is the better way (since in OAuth context I don't have username / password).
Hope my question is clear!
# app/config/security.yml
security:
encoders:
AppBundle\Entity\User:
algorithm: sha1
encode_as_base64: false
iterations: 1
providers:
my_custom_hwi_provider:
id: amagin_user.oauth_user_provider
in_memory:
memory:
users:
user: { password: userpass, roles: [ 'ROLE_USER' ] }
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_USER
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
default:
anonymous: ~
http_basic: ~
stateless: false
oauth:
resource_owners:
google: "/login/check-google"
login_path: /login
use_forward: false
failure_path: /login
oauth_user_provider:
service: amagin_user.oauth_user_provider
logout:
path: /logout
target: /
access_control:
#- { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/connect, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, role: ROLE_USER }