Installation
- grails create-project shiroPluginTest
- cd shiroPluginTest
- grails install-plugin shiro
- grails shiro-quick-start --prefix="Sec"
automatically create : domain/SecUser, domain/SecRole, controller/AuthController , Config/ShiroSecurityFilter - insert some data into Project. edit "Config/Bootstrap.groovy"Bootstrap.groovy
class
BootStrap {
def init = { servletContext ->
def u1 =
new
SecUser(username:
'user'
, passwordHash:
new
Sha1Hash(
'user'
).toHex())
u1.save()
def u2 =
new
SecUser(username:
'admin'
, passwordHash:
new
Sha1Hash(
'admin'
).toHex())
u2.save()
def role=
new
SecRole(name:
'user'
).addToUsers(u1)
role.addToPermissions(
"*:*"
)
role.save()
def role2=
new
SecRole(name:
'admin'
).addToUsers(u2)
role2.addToPermissions(
"*:*"
)
role2.save()
}
def destroy = {
}
}
- grails create-controller shiroTest
- grails generate-views shiroTest
- grails run-app
- try to go to any page, and see the login page is work correct
install the LDAP server
........(still working)
沒有留言:
張貼留言