Create a session


#1

Hello,
I develop a plugin to authentifie the user by a CAS but when the user connect this with the CAS, the session isn’t create. The result to the authentification with the CAS is valid, I have control this.
The code is :

        $authAdapter = new Omeka_Auth_Adapter_CAS('avignon.php', $recupInfoCAS);
        $result = $authAdapter->authenticate();

        if ($result->isValid()) {
            $session = new Zend_Session_Namespace;
//            Zend_Session::forgetMe();
            if ($session->redirect) {
                $this->_helper->redirector->gotoUrl($session->redirect);
            } else {
                $this->_helper->redirector->gotoUrl('/admin');
            }
        }
        else {
            $this->_helper->redirector->gotoUrl('/');
        }

Sorry for the spelling errors, I isn’t good in english.


#2

Hello @eragon12,

I have a plugin which supports CAS and LDAP authentication for Omeka Classic available here:

I found in developing the plugin one of the hardest challenges was making sure that Omeka and CAS would not destroy each other’s sessions.

Your code is too brief to see what may be going wrong. Is it within a UserController? If so, you may need to use the Zend_Auth object in $this->_auth to authenticate your adapter so Omeka is aware of the outcome. Line 2 would be:

$result = $this->_auth->authenticate($authAdapter);

This may not be sufficient to fix all of your issues, though.


#3

Hello @kloor,
Sorry for my tardiness.
My plugin have other specification and I prefer use phpCAS for facility and maintainability.
Omeka and the CAS don’t destroy other’s session.
I use a Controller for change this.
The code is accessible at this link https://github.com/MaximeBisotto/Omeka_AuthentificationPlugin


#4

Hello again @eragon12,

My best guess is that you do need to pass the adapter to $this->_auth->authenticate() so that Omeka can store the result before returning it to your controller. Otherwise, Omeka wont be aware that the user is authenticated, and wont store the redirect into the session.


#5

How do we pass my adapter to $this->_auth ? With $this->_auth = $adapter or need to pass by a method ?


#6

In your user controller, replace:
$result = $authAdapter->authenticate();
With:
$result = $this->_auth->authenticate($authAdapter);


#7

My adapter don’t work now, I search the problem


#8

Now my adapter isn’t call, I have only a white screen and don’t print every “echo” do in the adapter.


#9

I need use the filter loginAdapter or not because
$result = $this->_auth->authenticate($authAdapter);
don’t use my adapter. I use the login with the CAS at the route ‘/users/cas’ not /users/login’ so I can’t use
$adapter = $this->_getAdapter();


#10

It’s good, I have just forget the line

 $this->_auth = $this->getInvokeArg('bootstrap')->getResource('Auth');

Thanks you @kloor