Grails Framework: Difference between revisions

From Objectif Client Inc
Jump to navigation Jump to search
(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....")
 
Line 2: Line 2:


===Security Setup===
===Security Setup===
## Add security addon inside Build Config to enable Security addon  
# Add security addon inside Build Config to enable Security addon  
<syntaxhighlight lang="groovy">
<syntaxhighlight lang="groovy">
compile ':spring-security-core:2.0-RC4'
compile ':spring-security-core:2.0-RC4'
</syntaxhighlight>
</syntaxhighlight>
## Compile the application to finalise the installation and download necessary library. From grails command line execute "complile"
# 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:  
# Execute the script s2-quickstart to generate domains and update the configuration. From grails command line execute the following command:  


<syntaxhighlight lang="groovy">
<syntaxhighlight lang="groovy">
Line 14: Line 14:
</syntaxhighlight>
</syntaxhighlight>


## Preload security by addind following info into BootStrap config file under "def init = { servletContext ->"
# Preload security by addind following info into BootStrap config file under "def init = { servletContext ->"
<syntaxhighlight lang="groovy">
<syntaxhighlight lang="groovy">
   if (!User.count()) {
   if (!User.count()) {

Revision as of 04:35, 13 December 2014

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)
   }