Grails Framework

From Objectif Client Inc
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....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Framework Setup

Security Setup

    1. Add security addon inside Build Config to enable Security addon
compile ':spring-security-core:2.0-RC4'
    1. Compile the application to finalise the installation and download necessary library. From grails command line execute "complile"
    1. 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
    1. 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)
   }