jeremykendall / slim-auth

Authorization and authentication for the Slim Framework using ZF2 Authentication and Acl components
MIT License
244 stars 38 forks source link

Session issues #9

Closed Siim closed 9 years ago

Siim commented 10 years ago

Hi.

I followed your README to setup slim-auth. Now I have some issues with session persistence - I created admin user and I can log in with it.

However if I try to use some protected routing, the session could not remember that user is logged in.

I followed the code and tried to understand, whats wrong. So I found out that if AuthorizationMiddleware is initialized, it will get $auth and $acl objects. In AuthorizationMiddleware's constructor function the $auth->getStorage()->read() will reveal the correct session data. Now if I debugged the AuthorizationMiddleware call() method then $this->auth->getStorage()->read() is empty. I cannot figure out what's wrong with it.

jeremykendall commented 10 years ago

Thanks for the bug report. Life is insanely busy for me right now. I promise I'll get to this and try and sort it out ASAP, I just can't promise when that will be.

Siim commented 10 years ago

Hi. It seems that it will work with Zend session storage. I don't know if it is the right/best way to do the initial setup...

$acl = new Siim\Acl();

// use Zend sessionstorage
$storage = new Zend\Authentication\Storage\Session('Siim');

// commented out Slim sessioncookie
//$sessionCookie = new \Slim\Middleware\SessionCookie();

$authBootstrap = new Bootstrap($app, $adapter, $acl);

// set Zend session storage
$authBootstrap->setStorage($storage);
$authBootstrap->bootstrap();

// commented out
//$app->add($sessionCookie);
jeremykendall commented 10 years ago

What's the status of this for you, @Siim? Have you decided to use Zend\Authentication\Storage\Session or would you like me to dig into this and see why you were having issues with another session storage?

If you'd like me to dig in, would you please provide an example of how you configured Slim Auth when the session storage was failing so I can review it? Thanks!

jeremykendall commented 9 years ago

Hey @Siim,

I still have no idea why you experienced the issues you experienced, but since Slim 2.6.0 I was experiencing something similar. I've dropped the recommendation to use Slim's SessionCookie middleware and done some refactoring around Zend Session. Check out the latest release for more: 0.0.7-alpha.