Grails Framework
Revision as of 04:34, 13 December 2014 by Nicolas Rollin (talk | contribs) (Created page with "==Framework Setup== ===Security Setup=== ## Add security addon inside Build Config to enable Security addon <syntaxhighlight lang="groovy"> compile ':spring-security-core:2....")
Framework Setup
Security Setup
- Add security addon inside Build Config to enable Security addon
compile ':spring-security-core:2.0-RC4'
- 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)
}