https://github.com/garlicservices/user-bundle
Users Symfony 4 bundle for Garlic framework, that contains registration, login, password restore etc. features
https://github.com/garlicservices/user-bundle
composer-package symfony-bundle
Last synced: about 2 months ago
JSON representation
Users Symfony 4 bundle for Garlic framework, that contains registration, login, password restore etc. features
- Host: GitHub
- URL: https://github.com/garlicservices/user-bundle
- Owner: garlicservices
- License: mit
- Created: 2018-04-18T12:18:51.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-15T14:29:56.000Z (over 6 years ago)
- Last Synced: 2025-03-24T18:11:21.096Z (2 months ago)
- Topics: composer-package, symfony-bundle
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 3
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: Security/AuthenticationFailureHandler.php
Awesome Lists containing this project
README
Garlic User bundle
=====================
This bundle helps create Users service based on Garlic framework### User bundle based on FOSUserBundle
### Installation
#### 1. Run:
```bash
$ composer require garlic/user
```#### 2. Add to .env.dist (.env):
```bash
# Social login
FACEBOOK_CLIENT_ID=example_client_id
FACEBOOK_CLIENT_SECRET=example_secret
SOCIAL_ERROR_TTL=300# Mailer config
MAILER_USER=admin
MAILER_PASSWORD=null
[email protected]# Main admin credentials
ROLE_ADMIN_USER=admin_user_name
ROLE_ADMIN_PASSWORD=admin_password# Ldap host (use if configured)
LDAP_HOST=example.ldap.host
APPLICATION_TOKEN=31ae66c47c0c6373434b3e431fdf8gh
PROTOCOL=http# Image settings
AVATAR_DIRECTORY=public/avatar
AVATAR_RELATIVE_DIRECTORY=public/avatar```
#### 3. Add routing configuration (change config/routes.yaml):
```yaml
registration:
resource: "@GarlicUserBundle/Controller/RegistrationController.php"
type: annotationuser:
resource: "@GarlicUserBundle/Controller/UserController.php"
type: annotationresetting:
resource: "@GarlicUserBundle/Controller/ResettingController.php"
type: annotationtwo_factor:
resource: "@GarlicUserBundle/Controller/TwoFactorController.php"
type: annotationavatar:
resource: "@GarlicUserBundle/Controller/AvatarController.php"
type: annotationjwt:
resource: "@GarlicUserBundle/Controller/JwtController.php"
type: annotationsocial_connect:
resource: "@GarlicUserBundle/Controller/SocialConnectController.php"
type: annotation
```#### 4. Add Security configuration (change packages/security.yaml):
```yaml
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
FOS\UserBundle\Model\UserInterface: bcrypt
Garlic\User\Security\LdapUser: bcryptrole_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMINproviders:
chain_provider:
chain:
providers: [in_memory, fos_userbundle, ldap]in_memory:
memory:
users:
admin_user_name: # User name
password: admin_password # password
roles: ROLE_ADMINfos_userbundle:
id: fos_user.user_provider.username_emailldap:
ldap:
service: Symfony\Component\Ldap\Ldap
base_dn: cn=users,cn=accounts,dc=rghub,dc=pro
search_dn: ~
search_password: ~
default_roles: ROLE_EDITOR
uid_key: uidfirewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: falselogin:
pattern: ^/login
stateless: true
anonymous: true
provider: chain_providerform_login:
check_path: /login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: falseform_login_ldap:
check_path: /login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
service: Symfony\Component\Ldap\Ldap
query_string: 'uid={username}'
dn_string: 'cn=users,cn=accounts,dc=rghub,dc=pro'secured_area:
pattern: ^/social/
provider: chain_provider
oauth:
resource_owners:
facebook: /social/login_facebook
google: /social/login_google
youtube: /social/login_youtube
instagram: /social/login_instagram
login_path: /social/login
failure_path: /social/login
check_path: /social/login_check
success_handler: hwi_oauth_authentication.handler.authentication_success
oauth_user_provider:
service: hwi_oauth.user.provider.entityanonymous: ~
editor:
pattern: ^/admin/
http_basic_ldap:
provider: ldap
service: Symfony\Component\Ldap\Ldap
query_string: 'uid={username}'
dn_string: 'cn=users,cn=accounts,dc=rghub,dc=pro'main:
pattern: ^/
provider: fos_userbundle
stateless: true
anonymous: true
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticatoraccess_decision_manager:
strategy: unanimousaccess_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register/*, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/social/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }```
#### 5. Add two factor login configuration (change packages/scheb_two_factor.yaml):
```yaml
parameters:
scheb_two_factor.security.check_path: two_factor_loginservices:
scheb_two_factor.security.google.provider:
class: Garlic\User\Security\TwoFactorProvider
arguments:
- '@scheb_two_factor.security.google.code_validator'
- '%scheb_two_factor.parameter_names.auth_code%'
tags:
- { name: 'scheb_two_factor.provider', alias: 'google'}scheb_two_factor.trusted_filter:
class: Garlic\User\Security\TrustedFilter
arguments:
- '@scheb_two_factor.provider_registry'
- '@scheb_two_factor.trusted_cookie_manager'
- '%scheb_two_factor.trusted_computer.enabled%'
- '%scheb_two_factor.parameter_names.trusted%'scheb_two_factor.security.google.renderer:
synthetic: truescheb_two_factor:
trusted_computer:
enabled: true
cookie_name: two_factor_trusted_computer
cookie_lifetime: 5184000 # 60 days# Google Authenticator config
google:
enabled: true # If Google Authenticator should be enabled, default false
server_name: example.server.name # Server name used in QR code
issuer: Sequrity # Issuer name used in QR code
template: ~ # Template used to render the authentication formsecurity_tokens:
- Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken
- Lexik\Bundle\JWTAuthenticationBundle\Security\Authentication\Token\JWTUserTokenmodel_manager_name: ~
persister: scheb_two_factor.persister.doctrine
parameter_names:
auth_code: _auth_code # Name of the parameter containing the authentication code
trusted: _trusted # Name of the parameter containing the trusted flag```