silexphp / Silex

[DEPRECATED -- Use Symfony instead] The PHP micro-framework based on the Symfony Components
https://silex.symfony.com
MIT License
3.58k stars 718 forks source link

SecurityServiceProvider - Logging out #423

Closed drefined closed 11 years ago

drefined commented 12 years ago

The fix to issue #409 works perfectly, but now when I try to log out, nothing happens. It seems the session is still there.

Regards, David

fabpot commented 12 years ago

I don't have this issue (and anyway, it cannot be related to my fix for #409). Can you double-check your code? If you cannot find the issue, can you copy/paste a small-one-file-app that demonstrates the problem? Thanks.

drefined commented 12 years ago

It's just a simple app that does login and logout. For some reason, the logout does not do anything as I was still able to access admin after logout. Am I missing something? https://gist.github.com/3072797

stof commented 12 years ago

your logout path needs to be in the scope of the firewall, otherwise the firewall cannot handle the logout.

drefined commented 12 years ago

@stof Could you please provide an example? TIA :)

stof commented 12 years ago

/logout does not match your pattern which is ^/admin/?. you should use /admin/logout

drefined commented 12 years ago

@stof, sorry that still didn't work for me.

Bieleke commented 12 years ago

Neither works for me. $app['security.firewalls'] = array( 'admin' => array( 'pattern' => '^/admin/', 'form' => array('login_path' => '/login', 'check_path' => '/admin/login_check'), 'logout' => array('logout_path' => '/logout'), 'users' => array( // raw password is foo 'admin' => array('ROLE_ADMIN', '5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg=='), ), ), );

Logout produces white screen, and no logout, i can still reach admin section after logout.

stof commented 12 years ago

Well, you config still uses /logout as logout path, which does not match the ^/admin/ regex.

Bieleke commented 12 years ago

But does this means i have to have two firewall rules ? Or must we define two routes ?

Never mind, i have looked at how fos userbundle was doing it in symfony and copied that, works as a charm.

sunra commented 12 years ago

In early faced with the same problem of a white screen, when did everything in the documentation. But adjusting to the way he went into the path of a protected area - it worked! So? solution is: https://github.com/fabpot/Silex/issues/423#issuecomment-6835122

greygore commented 11 years ago

I too was tripped up by this; hopefully a little clarification in the docs will help.