-
Notifications
You must be signed in to change notification settings - Fork 8
How to use it
This module allows you to set up an authentication with a CAS server and to managed authorization. It is based on the Secure module.
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
In the conf/route file, import the default routes by adding this line :
# Import Secure routes * / module:logisima-cas
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
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(); } }
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); } }
In your application, if you want to know who is connected (the username), you can call the static method Security.connected().