Grails Framework: Difference between revisions

From Objectif Client Inc
Jump to navigation Jump to search
Line 2: Line 2:


===Security Setup===
===Security Setup===
* Add security addon inside Build Config to enable Security addon  
* Add security addon inside BuildConfig configuuration file to enable Security core and UI addon  
<syntaxhighlight lang="groovy">
<syntaxhighlight lang="groovy">
compile ':spring-security-core:2.0-RC4'
compile ':spring-security-core:2.0-RC4'
compile ":spring-security-ui:1.0-RC2"
</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"

Revision as of 05:16, 13 December 2014

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
  • Review config configuration file to add access to your own