(Quick Reference)

3 Usage - Reference Documentation

Authors: David Estes

Version: 0.6.1

3 Usage

Now that the security bridge is configured, The spring security bridge can be used anywhere throughout your app by simply defining the sharedSecurityService.

The sharedSecurityService provides access to all methods created in the bridge, as well as some additional methods to make things a bit easier.

  • getCurrentUser()
  • getCurrentAccount()
  • getUserIdentity()
  • getAccountIdentity()
  • getCurrentUserDisplayName()
  • isAuthorized(object,action)
  • isLoggedIn()
  • hasAnyRole(role)
  • ifAuthorized(object,action,Closure code)

For More methods please take a look at your SecurityBridge interface.

Secure Annotation

The grails security bridge provides an annotation org.grails.plugin.securitybridge.Secure This annotation can be used on controllers or controller methods to restrict access.

class HomeController {

def index() {

}

@Secure(["AUTHORIZED"]) def settings() {

} }

You can also apply to the entire controller:

@Secure(["AUTHORIZED","ADMIN"])
class HomeController {

def index() {

}

def settings() {

} }

TagLibs

This plugin also provides some helpful taglibs that you can use within your application.

  • security:ifLoggedIn
  • security:ifNotLoggedIn
  • security:ifAuthorized - Takes controller: 'value', action:'value'
  • security:ifNotAuthorized - Takes controller: 'value', action:'value'
  • security:createLink - Shortcut for creating login/settings/logout links as mapped in security service.