dev-master
9999999-devSingle-sign-on bundle for Symfony2
MIT
The Requires
- php >=5.3.3
- symfony/symfony >=2.1
- ext-openssl *
login sso otp single-sign-on
Single-sign-on bundle for Symfony2
I am by no means a security expert. I'm not bad at it either, but I cannot vouch for the security of this bundle. You can use this in production if you want, but please do so at your own risk. That said, if you'd like to contribute to make this bundle better/safer, you can always create an issue or send a pull request., (*1)
This bundle provides an easy way to integrate a single-sign-on in your website. It uses an existing ('main') firewall for the actual authentication, and redirects all configured SSO-routes to authenticate via a one-time-password., (*2)
Install using composer:, (*3)
php composer.phar require "fm/sso-bundle"
Enable the bundle in the kernel:, (*4)
``` php // app/AppKernel.php $bundles[] = new FM\SingleSignOnBundle\FMSingleSignOnBundle();, (*5)
Configuration ------------- Enable sso-routes: ``` yaml # app/config/routing.yml: sso: resource: . type: sso otp: # this needs to be the same as the check_path, specified later on in security.yml pattern: /otp/
The bundle relies on an existing firewall to provide the actual authentication. To do this, you have to configure the single-sign-on login path to be behind that firewall, and make sure you need to be authenticated to access that route., (*6)
``` yaml, (*7)
fm_single_sign_on: host: mydomain.com login_path: /sso/, (*8)
``` yaml # app/config/security.yml security: access_control: - host: mydomain.com path: ^/sso/$ roles: [IS_AUTHENTICATED_FULLY]
``` yaml, (*9)
security: firewalls: main: pattern: ^/, (*10)
This makes sure the user has to authenticate first (using a login form). Now for each firewall (other than the main one), you can configure single-sign-on authentication using a one-time-password. The only thing you have to provide is a path and user provider. Everything else is handled by the bundle. ``` yaml # app/config/security.yml: security: firewalls: sso: pattern: ^/ fm_sso: provider: main check_path: /otp/ # path where otp will be authenticated
That's it, you're done!, (*11)
Because we're working with multiple domains here, it's wise to configure the firewalls to only work for specific domains.
Say we have domain A and B. Domain A is where the single-sign-on is done (main
firewall), and domain B is authenticated by the one-time-password (sso
firewall).
We can use a request matcher service that confines the firewalls to specific domains. First we have to configure the request matchers:, (*12)
``` yaml, (*13)
security: firewalls: main: request_matcher: my.security.request_matcher.main sso: request_matcher: my.security.request_matcher.sso, (*14)
Now we can implement them as services: ``` yaml # src/MyAwesomeBundle/Resources/config/services.yml services: my.security.request_matcher.main class: %security.matcher.class% arguments: ["/", "domain-a.com"] my.security.request_matcher.sso class: %security.matcher.class% arguments: ["/", "domain-b.com"]
Single-sign-on bundle for Symfony2
MIT
login sso otp single-sign-on