BeSimple / BeSimpleSsoAuthBundle

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

Login check, login #60

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hello, i'm newbie with symfony 2 and i'm currently trying to use ssoauth bundle. I have few problems : first when i try to go on one of my webpages, a box tells me : "An error occurred while loading the web debug toolbar (500: Internal Server Error). Do you want to open the profiler?" If I click on Cancel button, the box disappears. Then, every webpages are replace with this text : "You need to authenticate A Token was not found in the SecurityContext. Follow this link to authenticate with external server : https://xxx.fr/xxx-cas-server/login?service=xxxx"

I click on the link, i log in but then symfony goes to app_dev/login_check which is a totally blank page.

What should I do to don't see the box error again ? And why it doesn't redirect me to the webpage I asked first instead of a blank page ? Here is my config :

security.yml

security: encoders: Symfony\Component\Security\Core\User\User: plaintext

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

providers:
    in_memory:
        memory:
            users:
                user:  { password: userpass, roles: [ 'ROLE_USER' ] }
                admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

firewalls:
    my_firewall:
        trusted_sso:
            manager: admin_sso
            login_action: BeSimpleSsoAuthBundle:TrustedSso:login
            logout_action: BeSimpleSsoAuthBundle:TrustedSso:logout
            create_users: true
            created_users_roles: [ROLE_USER, ROLE_ADMIN]

access_control:
    #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }

routing.yml

blogger_blog: resource: "@BloggerBlogBundle/Resources/config/routing.yml" prefix: / login: pattern: /login logout: pattern: /logout login_check: pattern: /login_check

config.yml

imports:

framework:

esi: ~

#translator:      { fallback: "%locale%" }
secret:          "%secret%"
router:
    resource: "%kernel.root_dir%/config/routing.yml"
    strict_requirements: ~
form:            ~
csrf_protection: ~
validation:      { enable_annotations: true }
templating:
    engines: ['twig']
    #assets_version: SomeVersionScheme
default_locale:  "%locale%"
trusted_hosts:   ~
trusted_proxies: ~
session:
    # handler_id set to null will use default session handler from php.ini
    handler_id:  ~
fragments:       ~
http_method_override: true

Twig Configuration

twig: debug: "%kernel.debug%" strict_variables: "%kernel.debug%"

Assetic Configuration

assetic: debug: "%kernel.debug%" use_controller: false bundles: [ ]

java: /usr/bin/java

filters:
    cssrewrite: ~
    #closure:
    #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
    #yui_css:
    #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

Doctrine Configuration

doctrine: dbal: driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: UTF8

if using pdo_sqlite as your database driver, add the path in parameters.yml

    # e.g. database_path: "%kernel.root_dir%/data/data.db3"
    # path:     "%database_path%"
orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true

Swiftmailer Configuration

swiftmailer: transport: "%mailer_transport%" host: "%mailer_host%" username: "%mailer_user%" password: "%mailer_password%" spool: { type: memory } be_simple_sso_auth: admin_sso: protocol: id: cas version: 2 server: id: cas login_url: https://xxx.fr/xxxx-cas-server/login logout_url: https://xxx.fr/xxx-cas-server/logout validation_url: https://xxxx.fr/xx-cas-server/serviceValidate

Thank you.

ghost commented 10 years ago

I've put false in login_action and logout_action and now, it redirects the web app to the server CAS form instead of printing "you need to authenticate..." and so the error box disappeared. So the only problem for now, is that after login in, it does not redirect me on my webapp. It's still a blank page with something like ......./app_dev/login_check?ticket=ST-10785-mWPJZvtdT2uoqUMCBqU9-xxxxxxx.fr

jsa-sf commented 10 years ago

I have the same result...

jsa-sf commented 10 years ago

Hello protecta, have you solved this problem ? I have the same with no solution. Thank you.

ghost commented 10 years ago

Hi, yes kind of. In your security.yml, try :

firewalls: my_firewall: pattern: ^/ anonymous: ~ trusted_sso: manager: admin_sso

            login_action: false         #

BeSimpleSsoAuthBundle:TrustedSso:login logout_action: false # BeSimpleSsoAuthBundle:TrustedSso:logout create_users: true created_users_roles: [ROLE_USER ]

            check_path: /check_path
        logout:
            path: /logout

I hope it will work for you, this bundle brings one more problem each time you solve one another...

2014-02-26 14:03 GMT+01:00 Jérémy SAFONT notifications@github.com:

Hello protecta, have you solved this problem ? I have the same with no solution. Thank you.

Reply to this email directly or view it on GitHubhttps://github.com/BeSimple/BeSimpleSsoAuthBundle/issues/60#issuecomment-36122335 .

jsa-sf commented 10 years ago

Hello,

Thank you for your reply. However it still does not work, I have a blank page on the url /check_path?ticket=ST-1257298-1rZxpPhpCQBu0BZz4NL4-***********.fr

On my routing file, I have this:

login_check:
    pattern: /check_path
logout:
    pattern: /logout

And I tried this for trying to manage tickets:

login_check:
    pattern: /check_path/{ticket}
    defaults: {ticket: null}
logout:
    pattern: /logout

And nothing work, how do you solve this ? Thank you.

ghost commented 10 years ago

Well, I have the same config as yours so... I don't know :/ This bundle is not documented enough unfortunately.

2014-02-27 9:34 GMT+01:00 Jérémy SAFONT notifications@github.com:

Hello,

Thank you for your reply. However it still does not work, I have a blank page on the url /check_path?ticket=ST-1257298-1rZxpPhpCQBu0BZz4NL4-***.fr

On my routing file, I have this:

login_check: pattern: /check_path

logout: pattern: /logout

And I tried this for trying to manage tickets:

login_check: pattern: /check_path/{ticket} defaults: {ticket: null}

logout: pattern: /logout

And nothing work, how do you solve this ? Thank you.

Reply to this email directly or view it on GitHubhttps://github.com/BeSimple/BeSimpleSsoAuthBundle/issues/60#issuecomment-36220713 .

jsa-sf commented 10 years ago

Je vais écrire en français, il me semble qu'on l'est tous les deux, ça sera plus simple pour moi d'exprimer mon problème et j'irai plus vite.

En fait j'ai l'impression que mon problème vient du provider. J'utilise une classe sans mot de passe car je veux justement que ce soit cette authentification CAS qui les gère.

Du coup pour adapter la classe à la BDD de l'université où je travaille, j'ai fais ça

class Annuaire implements UserInterface {

/*...*/

/**
 * @var string
 *
 * @ORM\Column(type="string", length=24, nullable=true, name="uidinterne")
 */
private $uidinterne;

/*...*/

private $password;
private $salt;

public function getRoles() {
 // TODO: Auto-generated method stub
}

public function getPassword() {
 return $this->password;
}

public function getSalt() {
 return $this->salt;
}

public function getUsername() {
 return $this->uidinterne;
}

public function eraseCredentials() {
 // TODO: Auto-generated method stub
}

/*...*/
}

Et j'ai ça dans mon security.yml

    providers
        annuaire:
            entity:
                class: *********\******Bundle\Entity\Annuaire
                property: username

Donc ça doit être ça qui ne va pas, mais je ne trouve pas comment l'adapter à mon cas.

Du coup j'ai essayé de l'adapter avec le provider in_memory Et ça ne me fait plus cette page blanche mais j'ai ce message d'erreur:

Unable to find the controller for path "/login". Maybe you forgot to add
the matching route in your routing configuration?

Je ne sais pas quoi mettre comme controller pour le /login, étant donné que c'est le serveur CAS qui est sensé s'en charger...

Merci d'avance, et désolé si vous n'êtes pas anglais, dites moi, je ferai l'effort de traduire Thank you in advance, and sorry if you are not English, tell me, I will do the effort to translate