PRayno / CasAuthBundle

Basic CAS (SSO) authenticator for Symfony (version 3,4 and 5)
MIT License
16 stars 19 forks source link

Authentication sso is true but role is false ?? #10

Closed sebius77 closed 6 years ago

sebius77 commented 6 years ago

Hi, I works on Symfony 4 and I want use a SSO Authentication. I saw your library . I saw that it work with guard. I test it and the redirection work to the sso but I don't know how to do when authentication is true but the role ROLE_USER don't exist. On the server symfony I have an error : Access denied, the user is not fully authenticated and redirect user to the sso but he's yet connected. I would like to redirect to template with error message. I need your help to understand.

Next, I would like to adapt your library to Symfony 4.

Thanks.

junowilderness commented 6 years ago

Create a user class implementing UserInterface and a user provider for it implementing UserProviderInterface. Use UserProviderInterface::loadUserByUsername() to add default roles. Specify this custom provider class id for "cas":

In security.yml:

security:

    providers:
        cas:
          id: App\User\MyUserProvider
junowilderness commented 6 years ago

I just now submitted PR #11 to make this compatible with Symfony 4.

sebius77 commented 6 years ago

I'll test as soon as I can. Thank you very much

junowilderness commented 6 years ago

@sebius77 That PR is working fine for me on two SF4 apps.

For easy testing, add this to the app's composer.json:

    "repositories": [
        {
            "type": "vcs",
            "url":  "git@github.com:cilefen/CasAuthBundle.git"
        }
    ]

And require the PR's branch:

composer require prayno/casauth-bundle:dev-sf4-compatibility
junowilderness commented 6 years ago

I should add that you could also specify default roles in the custom user class implementing UserInterface.

junowilderness commented 6 years ago

@sebius77 It's been merged so only this is needed:

composer require prayno/casauth-bundle:dev-master
PRayno commented 6 years ago

Thanks for this PR @cilefen , I just couldn't find time to do this work. I think it might also require symfony/security-bundle to get the security.yaml file

junowilderness commented 6 years ago

I am happy to help.

I think no on security-bundle unless this bundle absolutely requires it.

On Mar 15, 2018, at 12:19 PM, Pierre Raynaud notifications@github.com wrote:

Thanks for this PR @cilefen , I just couldn't find time to do this work. I think it might also require symfony/security-bundle to get the security.yaml file

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

PRayno commented 6 years ago

I published a new version on packagist so you just need :

composer require prayno/cas-authbundle