Plugins You can find out about all the publicly available Grails plugins.

OpenSSO Plugin

  • Tags: security
  • Latest:
  • Last Updated: 28 November 2010
  • Grails version: *
  • Authors: null
0 vote
compile "org.grails.plugins:opensso:"



NOTE: Plugin download link is currently broken

I am having challenges with release-plugin. Please download the plugin here until I can get it fixed- Warren


Integrates Grails with OpenSSO. The plugin delegates authentication and authorization to OpenSSO.It provides the following features:

  • Single Sign On with OpenSSO.
  • URL policy enforecement is delegated to opensso
  • Grails gsp security tags can be used.
  • Security methods are dynamically added to controllers
For more information please see Warren's blog

Grails OpenSSO Plugin Notes


The OpenSSO plugin allows your Grails application to use OpenSSO for authentication and authorization. The plugin provides the following functionality :

Single Sign On (SSO) with OpenSSO:

The plugin delegates logon to OpenSSO. If the user has previously authenticated to OpenSSO, the browser will present a cookie containing the SSO token. Providing the session is still valid, the user will be transparently signed on the Grails application. If the user does not have a token, the plugin redirects them to OpenSSO. After succesfull authentication, the user is then redirected back to the application.

This means that your application is not responsible for authentication. In fact, there are no logon or password screens to maintain as OpenSSO handles it for you. One of the nice benefits of this approach is that the authentication method and strength is factored out of the application. Want to use one time passwords? How about AD? No problem - just configure the authentication chain in OpenSSO. No changes to your application.

URL Policy Enforcement

The plugin provides for enforcement of URL policy using OpenSSO. This works quite nicely with Grails and it's "REST" like structure for controller URLs. So we can (for example), allow one group of users to /list controller items, and another group of users to /update or /create new items. Custom controller methods (beyond the standard CRUD methods) can use the same mechanism.

Note that this largely eliminates the need for the @Secured annotations in Grails code - since the same effect can be implemented using URL policy. This externalizes the authorization into OpenSSO - which is generally a good thing.

Controller Security Methods

The plugin injects several security methods into your controllers to provide access to the security context. Here is sampling of methods available to controllers:

isUserInRole("ROLE_MANAGER")   - true if a user belongs to the specified Role
isUserLogon()    -  true if the user is logged on (authenticated)
getGrantedAuthorities() - returns an array of Strings representing the user's Granted Authorities (Spring terminology for role names).

GSP Tags

The plugin provides access to GSP security tags. These tags can be used in your Grails view to drive the display based on the user's role or authentication status.

For example:

<g:ifNotGranted role="ROLE_MANAGERS">You are not a Manager! </g:ifNotGranted>
<g:ifAllGranted role="ROLE_MANAGERS">Congrats. You are a manager!</g:ifAllGranted>

Using the Plugin

To use the plugin, you must complete the following steps:

  • Install the plugin using grails-install plugin
  • Create the file to point at your OpenSSO installation
  • Override any desired properties in OpenSSOConfig.groovy.
  • Create the necessary policies in OpenSSO to protect your application.
Note: The above assumes that you have previously deployed OpenSSO.

Let's look at these steps in more detail.

Installing the plugin

The plugin is installed using the command:

grails install-plugin opensso


The next step is to configure This property file must be found at runtime by the OpenSSO client SDK (openssoclientsdk.jar) that is included with the plugin. The best place to put it is in your src/java project directory.

The primary purpose of the property file is to help the client SDK communicate with the OpenSSO server at runtime. A complete discussion of this property file is beyond the scope of this document. The following resources are a good place to find out more:

Doc Teger's blog describes the purpose of AMConfig and how to create it.

The OpenSSO docs describes the property file in detail.

There is also a sample Grails application that you can look to for guidance. Download it from here

AMConfig looks somewhat daunting, but you can leave most properties as they are. The key things the client needs to know (that will be unique to your implementation) are the URLs of the OpenSSO server, and the credentials used by the client to communicate to OpenSSO.

You will probably want to turn on debugging during development. Here is an example of how to do that:

Create OpenSSOConfig.groovy

Next, override any defaults in your grails-app/conf/OpenSSOConfig.groovy file. The following is taken from the sample application:

opensso {
    active = true
     anonymousUrls = ['/', '/index.gsp' , '/auth/denied.gsp', '/images/*', '/css/*']
     loginUrl = ""

Anonymous URLs can be accessed by anyone, even if they have not authenticated. These are useful for landing pages, images and css.

Create Policies in OpenSSO

The next step is to create policies in OpenSSO to protect your application. A complete discussion of policy management is outside the scope of this document (please consult the OpenSSO documentation).

Here is small example used to protect the sample application (the URLs here are going to be different in your environment). The screen shot below shows the rule definition for denying access to “Manager” resources. Note the use of the wild card for URL matching:

The subject of the policy is configured to deny access to everyone who is NOT a manager (see the screen shot below). The “exclusive” check box indicates this applies to all subjects exclusive of those specified. In this example, it is everyone who is not in the OpenSSO managers group.

Next Steps

You should now be ready to test out the plugin. When you run your application (grails-run) and browse to the first protected page, you should see your browser get re-directed to OpenSSO for logon. Once authenticated you will be re-directed back to your application.

Check out the sample application for some ideas on using GSP security tags and programmatic security. For example, the main.gsp layout file has been modified to show the users logon name in the header:

      Logged in as: <g:loggedInUsername/>
      <a href="">Logout</a>

Note the use of the logout link. This performs an SSO logout and then redirects the user back to the application page.


  • Turn on debug output in
  • Use fully qualified domain names throughout your application and in OpenSSO. Opensso uses domain cookies to handle SSO. Trying to access “localhost” is a common source of problems. You can use “fake” dns names in your /etc/hosts file (or Windows equivalent) for development.
  • You may have to set cookie encoding to “true” in ( and in OpenSSO (Configuration->Servers and Sites->Security->Cookie). Note these two settings must be in sync with each other (if you set it on the client, you must set it on the server).

Getting Help

The OpenSSO users mailing list is a great place to get help. You can sign up at . The list is archived at


The plugin includes the following external dependencies:

  • openssoclientsdk.jar – The OpenSSO client SDK jar file
  • opensso-springsecurity-xx.jar – The OpenSSO Spring 2 Security provider. This is maintained in the OpenSSO extensions project at *
  • Spring Security – The various Spring security jar files


This plugin is based on and includes code from the Spring Security plugin.