Skip to content

Instantly share code, notes, and snippets.

@mlist
Created December 13, 2013 12:43
Show Gist options
  • Save mlist/7943689 to your computer and use it in GitHub Desktop.
Save mlist/7943689 to your computer and use it in GitHub Desktop.
how to apply security token service in a controller
private def accessAllowed = { securityToken, uuid ->
//check if user is authenticated
if(!springSecurityService.isLoggedIn()){
//alternatively check if a security token is provided
if(!securityToken || securityToken != uuid){
return(false)
}
}
return(true)
}
def someAction = {
def someObject = SomeObject.get(params.id)
if(accessAllowed(params.securityToken, someObject.uuid)){
//do stuff
}
else{
render status: 403
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment