GithubHelp home page GithubHelp logo

oefenweb / cakephp-uni-login Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 1.0 41 KB

A UNI•Login (Authentication) Plugin for CakePHP

License: MIT License

PHP 100.00%
cakephp cakephp-plugin plugin php user-management uni-login unilogin-login-procedure

cakephp-uni-login's Introduction

UniLogin plugin for CakePHP

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.

Requirements

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

Installation

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

Configuration

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

CakePlugin::load('UniLogin');

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');

Usage

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.

cakephp-uni-login's People

Contributors

mvdriel avatar tersmitten avatar

Watchers

 avatar  avatar  avatar

Forkers

mvdriel

cakephp-uni-login's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.