Difference between revisions of "Grails Plugins"
From Blue-IT.org Wiki
(→Annotate the controller actions) |
(→Create a currentUser() method in the controller) |
||
Line 69: | Line 69: | ||
class DomainClassController { | class DomainClassController { | ||
− | + | ||
@Secured(['ROLE_USER']) | @Secured(['ROLE_USER']) | ||
def myAction = { | def myAction = { | ||
Line 76: | Line 76: | ||
} | } | ||
− | + | ||
[...] | [...] | ||
'''private currentUser()''' { | '''private currentUser()''' { | ||
'''User.get(springSecurityService.principal.id)''' | '''User.get(springSecurityService.principal.id)''' |
Revision as of 08:23, 8 August 2011
All plugins can be downloaded at: http://grails.org/plugins
Contents
Multi Tenant
An introduction on the concept of multitenant can be found at:
Documentation
Spring Security
- http://www.grails.org/plugin/spring-security-core
- http://grails.org/dist/screencasts/screencast10.mov
s2-quickstart
grails s2quickstart your.package SecUser SecRole
creates two domain classes and corresponding controllers.
Integrade domain classes
class MyDomainClass extends SecUser { [...] }
BootStrap.groovy
class BootStrap { def dpringSecurityService def init = { def userRole = SecRole.findByAuthority("ROLE_USER") ?: new SecRole(authority: "ROLE_USER").save() def adminRole = SecRole.findByAuthority("ROLE_ADMIN") ?: new SecRole(authority: "ROLE_ADMIN").save() [...] } def users = User.list() ?: [] if (!users) { def user = new User( [...] password: springSecurityService.enodePassord("myPass") enabled = true ) } SecUserSecRole.create user, userRole }
Annotate the controller actions
import grails.plugins.springsecurity.Secured class DomainClassController { @Secured(['ROLE_USER']) def myAction = { [...] } }
Create a currentUser() method in the controller
class DomainClassController { @Secured(['ROLE_USER']) def myAction = { def currentUser = currentuser(); [...]
} [...] private currentUser() { User.get(springSecurityService.principal.id)