2013年1月18日 星期五

Installation for Shiro Plugin on Grails


Installation

  1. grails create-project shiroPluginTest
  2. cd shiroPluginTest
  3. grails install-plugin shiro
  4. grails shiro-quick-start --prefix="Sec"
    automatically create : domain/SecUser, domain/SecRole, controller/AuthController , Config/ShiroSecurityFilter
  5. 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 = {
        }
    }
  6. grails create-controller shiroTest
  7. grails generate-views shiroTest
  8. grails run-app
  9. try to go to any page, and see the login page is work correct
install the LDAP server
........(still working)

Reference:

沒有留言:

張貼留言