Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

How to use it

sim51 edited this page Oct 12, 2010 · 3 revisions

This module allows you to set up an authentication with a CAS server and to managed authorization. It is based on the Secure module.

Enable the LogiSima Play CAS

In the conf/application.conf file, enable the LogiSima Play CAS module with this line :

    # The logisima play cas module
    module.logisima-cas=${play.path}/module/logisima-play-cas

Import default routes

In the conf/route file, import the default routes by adding this line :

	# Import Secure routes
	*    /    module:logisima-cas

Configure the module

In the conf/application.conf file, you have to specified th cas login, validate and logout urls like this :

	cas.validateUrl=https://www.logisima.com/cas/serviceValidate
	cas.loginUrl=https://www.logisima.com/cas/loginUrl
	cas.logoutUrl=https://www.logisima.com/cas/logoutUrl

Protect a controller

To protect a controller, you just have to add this annotation : @With(SecureCAS.class).

Exemple:

@With(SecureCAS.class)
public class Application extends Controller {

    public static void index() {
        render();
    }

}

Add the authentication mechanisme

Once your application retrivied the username (login), you have to check the user’s information with your own mechanism. To do this, you just have to create a class in the controllers package that extends the controllers.SecureCAS.Security, and impement the following method :

public static boolean authentify(String username, String password).


Exemple :

	package controllers;
	 
	public class Security extends SecureCAS.Security {
	    
	    public static boolean authenticate(String username, String password) {
	        User user = User.find("byEmail", username).first();
	        return user != null && user.password.equals(password);
	    }    
	    
	}

Retrieving the connected user

In your application, if you want to know who is connected (the username), you can call the static method Security.connected().