Grails Framework
Framework Setup
Security Setup
- Add security addon inside BuildConfig configuuration file to enable Security core and UI addon
compile ':spring-security-core:2.0-RC4'
compile ":spring-security-ui:1.0-RC2"
- Compile the application to finalise the installation and download necessary library. From grails command line execute "complile"
- Execute the script s2-quickstart to generate domains and update the configuration. From grails command line execute the following command:
s2-quickstart com.objclt.application.security User Authority --groupClassName=Role
- Preload security by addind following info into BootStrap config file under "def init = { servletContext ->"
if (!User.count()) {
new User(username:'admin', password:'admin',enabled:true).save(failOnError:true)
}
if (!Role.count()) {
new Role(name:'ROLE_ADMIN').save(failOnError:true)
new Role(name:'ROLE_USER_MGT').save(failOnError:true)
}
if (!Authority.count()) {
new Authority(authority:'ROLE_ADMIN').save(failOnError:true)
new Authority(authority:'ROLE_USER_DSP').save(failOnError:true)
new Authority(authority:'ROLE_USER_CRT').save(failOnError:true)
new Authority(authority:'ROLE_USER_UPD').save(failOnError:true)
new Authority(authority:'ROLE_USER_DEL').save(failOnError:true)
}
if (!RoleAuthority.count()) {
new RoleAuthority(authority:1,role:1).save(failOnError:true)
new RoleAuthority(authority:2,role:2).save(failOnError:true)
new RoleAuthority(authority:3,role:2).save(failOnError:true)
new RoleAuthority(authority:4,role:2).save(failOnError:true)
new RoleAuthority(authority:5,role:2).save(failOnError:true)
}
if (!UserRole.count()) {
new UserRole(user:1,role:1).save(failOnError:true)
}
if (!UserAuthority.count()) {
new UserAuthority(user:1,authority:2).save(failOnError:true)
}
- Run the application "run-app" from grails command line
- Log into the application with user admin passsword admin
Security Setup
- Review config configuration file to add access to your own
- to customize the login script run the folowing script to duplicate it into your application
s2ui-override auth
- Now you got the file auth.gsp under login views folder