BeSimple / BeSimpleSsoAuthBundle

NOT MAINTAINED - SSO authentication providers (Cas for now) for Symfony2
125 stars 76 forks source link

Too many redirections #34

Open modlew opened 11 years ago

modlew commented 11 years ago

Hi everyone.

I just setup symfony and this bundle, I tried to configure it but it seems I am doing something wrong.

my security.yml contains :

    my_firewall:
        pattern: ^/
        trusted_sso:
            manager: admin_sso
            create_users: false
            login_action: false
            logout_action: false
            login_path: /login
            check_path: /login_check

my routing.yml contains :

    login:
        pattern:   /login

    login_check:
        pattern:   /login_check

and my config.yml contains :

    be_simple_sso_auth:
        admin_sso:
            protocol:
                id: cas
                version: 2
        server:
                id: cas
                login_url: https://cas.*.fr/login
                logout_url: https://cas.*.fr/logout
                validation_url: https://cas.*.fr/serviceValidate

So as defined in my security.yml, as soon as I try to browse my application, I am redirected to my cas login url, this is perfect. Anyway, when I login or when I am already logged, I have an error from my browser because of too many redirections :

    cas login --> sf login_check --> sf login --> cas login ...

Thank you in advance for any help you can provide me !

modlew commented 11 years ago

Hi again I think I found where the problem may come from.

I added my CAS login and password in the security.yml under :

    providers: 
       in_memory: 
          memory: 
             users:

And I don't have the "Too many redirections" problem anymore, it works perfectly.

Anyway, I would like my users to use an Entity instead of having to write their login and password in the security.yml, can someone explain me how to do so ?

Is it possible to have the bundle fill/create an User entity at login ?

Thank you in advance.

modlew commented 11 years ago

Can someone help me using this bundle please ? Thank you in advance.

ethanhann commented 11 years ago

You figured out that the reason why you were getting the "Too many redirections" issue was because you did not have a user provider specified.

To use an Entity you have to have an entity provider. You can create your own User provider, as documented here: http://symfony.com/doc/current/cookbook/security/custom_provider.html

Alternatively you can use an existing bundle with a user provider like FOSUserBundle: https://github.com/FriendsOfSymfony/FOSUserBundle

To use FOSUserBundle with BeSimpleSSOAuth you would add the former's user provider to the latter's firewall in your security.yml file, like so...

# app/config/security.yml
security:
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    my_firewall:
        pattern: ^/
        trusted_sso:
            manager: admin_sso
            create_users: false
            login_action: false
            logout_action: false
            login_path: /login
            check_path: /login_check
        provider: fos_userbundle
ethanhann commented 11 years ago

@modlew To answer your other question, this bundle is not capable of automatically creating a User entity on login as it does not fire an interactive login event and it also doesn't have a listener for an interactive login event. If this bundle did fire an interactive login event, you could create an interactive login listener in your own bundle that created or updated a user when they login.

ethanhann commented 11 years ago

@modlew It looks like I was incorrect about this bundle not being able to facilitate the creation of users when they successfully authenticate. It looks like it can authorize a user provider to create not found users if the provider implements the UserFactoryInterface. See: https://github.com/BeSimple/BeSimpleSsoAuthBundle/blob/master/Resources/doc/trusted.md