playtini / auth-bundle
Simple Google Account Authentication Symfony Bundle
Installs: 162
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.0
- doctrine/doctrine-bundle: ^1.6
- knpuniversity/oauth2-client-bundle: ^1.1
- league/oauth2-google: ^1.0
- symfony/security-guard: ^3.0
- twig/twig: ^2.1
Requires (Dev)
- phpunit/phpunit: ^5.6
- symfony/phpunit-bridge: ^3.0
README
Implementation of common authentication logic
Installation
- Use composer
Add parameters to app/config/parameters.yml.dist
parameters: google_app_id: something.apps.googleusercontent.com google_app_secret: your_secret google_app_domain: yourdomain.com google_app_users: user1,user2
You may add parameters to env-map:
"google_app_id": "GOOGLE_APP_ID",
"google_app_secret": "GOOGLE_APP_SECRET",
"google_app_domain": "GOOGLE_APP_DOMAIN",
"google_app_users": "GOOGLE_APP_USERS",
Install
composer require playtini/auth-bundle
- Add PlaytiniAuthBundle and KnpUOAuth2ClientBundle to
app/AppKernel.php
// app/AppKernel.php new \KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle(), new \Playtini\Bundle\AuthBundle\PlaytiniAuthBundle()
- Set
app/config/security.yml
security: encoders: Symfony\Component\Security\Core\User\User: algorithm: bcrypt # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers providers: database_users: entity: { class: 'Playtini\Bundle\AuthBundle\Entity\User', property: username } api_key_user_provider: id: playtini.auth.security.api_key_user_provider firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false api: pattern: ^/api/(?!key\.json) stateless: true simple_preauth: authenticator: playtini.auth.security.api_key_authenticator provider: api_key_user_provider main: pattern: ^/ logout: true anonymous: true guard: authenticators: - playtini.auth.security.google_authenticator entry_point: playtini.auth.security.google_authenticator remember_me: secret: "%secret%" lifetime: 31536000 # 365 days in seconds path: / domain: ~ # Defaults to the current domain from $_SERVER #always_remember_me: true access_control: - { path: ^/login/, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/, roles: ROLE_USER }
- Enable AuthBundle routing. Add to
app/config/routing.yml
playtini_auth: resource: "@PlaytiniAuthBundle/Resources/config/routing/routing.yml"
- Update your database schema