Cosign plugin


I am trying to access the admin page in Omeka using Cosign instead of enter a username and password to the omeka login page.

I created a plugin after getting some ideas from LDAP plugin.

Here is What I achieved so far:

I was able to access the admin page on Omeka after I login using Cosign username.
however, I still get the login page.

steps user need to follow to access the admin on omeka.

this takes me to the cosign page, I enter my user name and password. then this will take me to the omeka login page
I enter anything in user name and password bc they are required. I still get access to the admin bc I use the Cosign user name to pass it to the Adapter.

My problem how can I pass the admin Login screen to stop asking for username and password.

I saw that the login Action function in User controller class cause this login page to be initiated
but I did not know how to pass this step.

In my plugin.php I have the following code:

//Define hooks
add_plugin_hook('install', 'cosign_install');
///Define filters
add_filter('login_adapter', 'login');

function login($authAdapter,$loginForm) {
//retrieve username and password
$username =$_SERVER['REMOTE_USER'];
$pwd = '';//$_SERVER['REMOTE_USER'];

$authAdapter = new Omeka_Auth_Adapter_Cosign($username,$pwd);
return $authAdapter;

class Omeka_Auth_Adapter_Cosign implements Zend_Auth_Adapter_Interface {
private $omeka_userid;
public function __construct($username,$password) {
$this->omeka_userid = $username;

public function authenticate() {
// Omeka needs the user ID (not username)
$omeka_user = get_db()->getTable('User')->findBySql("username = ?", array($this->omeka_userid), true);
if ($omeka_user) {
$id = $omeka_user->id;
$correctResult = new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
return $correctResult;
else {
$messages = array();
$messages[] = 'Login information incorrect. Please try again.';
$authResult = new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $this->omeka_userid , $messages);

return $authResult;

Am I going in the right track?
What do I need to add to the plugin to pass the login screen?