Skip to content

Instantly share code, notes, and snippets.

@SCIF
Created July 19, 2015 06:43
Show Gist options
  • Save SCIF/67253b935d36c66960d6 to your computer and use it in GitHub Desktop.
Save SCIF/67253b935d36c66960d6 to your computer and use it in GitHub Desktop.
HWI and FOS integration
config.yml:
```
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: AppBundle\Entity\User
from_email:
address: %mail_sender_address%
sender_name: %mail_sender_name%
registration:
form:
type: modlette_user_registration
confirmation:
enabled: true
hwi_oauth:
# name of the firewall in which this bundle is active, this setting MUST be set
firewall_name: main
fosub:
properties:
linkedin: "linkedinId"
connect: ~
# confirmation: true # should show confirmation page or not
# registration_form_handler: my_registration_form_handler
# registration_form: oauth.user.registration.form.type
# account_connector: my_link_provider # can be the same as your user provider
# an optional setting to configure a query string parameter which can be used to redirect
# the user after authentication, e.g. /connect/facebook?_destination=/my/destination will
# redirect the user to /my/destination after facebook authenticates them. If this is not
# set then the user will be redirected to the original resource that they requested, or
# the base address if no resource was requested. This is similar to the behaviour of
# [target_path_parameter for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html).
# target_path_parameter: _destination
# an optional setting to use the HTTP REFERER header to be used in case no
# previous URL was stored in the session (i.e. no resource was requested).
# This is similar to the behaviour of
# [using the referring URL for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html#using-the-referring-url).
# use_referer: true
# here you will add one (or more) configurations for resource owners
# and other settings you want to adjust in this bundle, just checkout the list below!
resource_owners:
linkedin:
type: linkedin
client_id: %linkedin_client_id%
client_secret: %linkedin_client_secret%
scope: %linkedin_scopes%
```
security.yml:
```
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
main:
pattern: ^/
form_login:
login_path: "/login"
provider: fos_userbundle
csrf_provider: security.csrf.token_manager
logout: true
anonymous: true
oauth:
resource_owners:
linkedin: "/oauth/login/check-linkedin"
login_path: "/login"
check_path: "/oauth/login/login_check"
use_forward: false
failure_path: "/oauth/login"
oauth_user_provider:
service: hwi_oauth.user.provider.fosub_bridge
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/oauth/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment