Skip to content

Lagoon/PLint

Repository files navigation

PLint – Play!Framework 1.x Lagoon® Security Interface Connector

Description

PLint is a connector module to easily integrate your applications with Lagoon® Security, which is an authentication/authorization system developed by XLM – Innovation & Technology.
This way managing your applications authentication and authorization is made very simple.

Adding Module to your project

After downloading the module, unzip it and put it in the same folder as your application, then add to dependencies.yml of your application:

require:
    - PLint -> PLint

repositories:
    - MyModules:
       type:    local
       artifact: "${application.path}/../../../[module]"
       contains:
            - PLint

Note: For this dependency to work the module has to be in a folder named PLint.

And then execute:
$ play deps
Don’t forget to execute $ play eclipsify to enable it in eclipse.

Configuration

After installing PLint, in order to use it in your Play! Application, the following configurations must be made on application.conf:

lint.protocol=https // Communication Protocol with LS
lint.port=9091 // Communication Port with LS
lint.baseUrl=demo.lagoonsecurity.pt // Provided LS Base access URL
lint.login=loginLagoon // Provided LS Login
lint.password=passwordLagoon // Provided LS password

The baseUrl, login and password will be provided after registration. To check your credentials please go to Lagoon® Security

How to use

Automatic Controller Protection
To secure your controllers with Lagoon® Security and use the provided login panels, the following annotation must be added to the controller to protect it:

@With(SecureLint.class)
public class MyController extends Controller{
}

To use default PLint routes, in the conf/routes file, import the default module routes by adding this line:

* / module:PLint

Custom Controller Protection
You already have your own login panels? No problem use the following annotation to the controllers you want to be protected:

@With(Lint.class)
public class MyController extends Controller{
}

In this option the external user id (Lagoon user ID) must be added to the session with the key id. If your application is configured to use contexts, you also need to add to the session the context name with the key context.

Advanced Controller Protection
If you want to control access at your own or for more advanced operations, use the LintRobot class methods, in your controllers.

To check the available methods of PLint see the documentation.

Example Application

In samples-and-tests you can find an example application using PLint named marketSample which simulates an application where users can buy and sell several items.
Before running the application don’t forget to run the command:
play deps

The URL to enter the test application as administrator (access marketSample administration area) is:
http://admin.lvh.me:9000
login: admin
password: admin

To enter as a normal user the URL is: http://marketsample.lvh.me:9000, here you can register (just store login and password) the application users.

Go to Lagoon® Security so you can change the access configurations of the users from marketSample to the several resources.