A UNI•Login (Authentication ) Plugin for CakePHP

Installs: 11 447

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 1

Open Issues: 1


v2.0.0 2019-01-23 12:29 UTC

This package is auto-updated.

Last update: 2024-04-24 03:34:52 UTC


Build Status PHP 7 ready Coverage Status Packagist downloads Code Climate Scrutinizer Code Quality

This plugin handles (single sign on) authentication with UNI•Login. UNI•Login is a service that provides authentication, access control and user administration to providers of web-based applications in the educational sector.


  • CakePHP 2.9.0 or greater.
  • PHP 7.0.0 or greater.


Clone/Copy the files in this directory into app/Plugin/UniLogin


Ensure the plugin is loaded in app/Config/bootstrap.php by calling:


Ensure to configure the following lines in app/Config/bootstrap.php:

// Application / plugins communication
Configure::write('UniLogin.application.completeUrl', '/uni_login_logins/login_complete');
Configure::write('UniLogin.application.secret', 'appSecret');

// Plugins provider communication
Configure::write('UniLogin.provider.url', 'https://sli.emu.dk/unilogin/login.cgi');
Configure::write('UniLogin.provider.applicationId', '1');
Configure::write('UniLogin.provider.secret', 'providerSecret');

// Plugins (test)provider communication
Configure::write('UniLogin.testProvider.defaultRedirectUrl', '/uni_login/uni_login/callback');
Configure::write('UniLogin.testProvider.applicationId', '1');
Configure::write('UniLogin.testProvider.user', 'testUser');


Minimal setup for UniLogin login procedure

class UsersController extends AppController {

	public function login_start() {
		$returnUrl = Router::url(['action' => 'login_complete']);
		$url = ['plugin' => 'uni_login', 'controller' => 'uni_login', 'action' => 'login', '?' => ['returnUrl' => $returnUrl]];
		return $this->redirect($url);

	public function login_complete() {
		$secret = Configure::read('UniLogin.application.secret');
		if (!hash_equals($secret, $this->request->data('secret'))) {
			throw new ForbiddenException();

		if ($this->request->data('validated') === true) {
			$key = $this->request->data('user');

			// Find application user by key and login user


The UsersController::login_start starts the UniLogin login procedure, the UsersController::login_complete handles the callback from UniLogin.