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 thesharedSecurityService
.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)
Secure Annotation
The grails security bridge provides an annotationorg.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() { }
}
@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.