SPEP Grails Plugin

This is a placeholder page for the new SPEP Grails plugin. More documentation will appear here as it is written.

Prerelease

The SPEP Grails Plugin is in a prerelease state. As such, the deployment and configuration are not polished and the code has not been thoroughly tested. Use this at your own risk.

Acquiring the source code

You can check out the source for this plugin with:

svn checkout https://esoeproject.org/repos/esoe/trunk/spepintegrators/grails grails-spep

For the present time, the SPEP filter and dependency jars need to be manually inserted in grails-spep/lib before building the plugin via:

grails prod package-plugin

Installation

As with all standard grails plugins, this can be installed with the grails install-plugin command, i.e.:

grails install-plugin /path/to/grails-spep-0.2.zip

Upon installation, the plugin will create web-app/META-INF/context.xml if it does not already exist. The important part of this xml file is the crossContext="true" attribute, which enables the SPEP filter to access the SPEP war context.

Development version

A development version of the plugin can be built with:

grails dev package-plugin

This development version injects a configurable set of attributes into the user object, rather than retrieving them from the web environment. This allows testing of the application without setting up an SPEP. To configure the attributes, put the following piece of config in your application config, and edit the attributes to suit:

spep {
    devAttributes {
        uid = ["test"]
        name = ["Test user"]
    }
}

Note that all SPEP attributes are treated as multi-valued, so each attribute should be a list of values, even if only one value is set.

If no attributes are specified, the user object is populated as if the user had authenticated successfully with no attributes. This behaviour will likely change in a future version.

Attributes in application code

To access the devAttributes shown above, the following example code can be used:

TestController.groovy

class TestController {
    def spepUser

    def index = { return [authenticated:spepUser.authenticated, uid:spepUser.uid[0], name:spepUser.name[0]] }
}

index.gsp

<html><head><title>Welcome!</title><meta name="layout" content="main"/></head><body>

    <h2>Welcome, ${name}</h2>
    <p>Your uid is: ${uid}</p>
    <g:if test="${authenticated}">
        <p>You are authenticated</p>
    </g:if>

</body></html>

Also available in: HTML TXT