- Create new Grails application project.
- Create a new domain class using 'grails create-domain-class domain' and make sure the name does not have 'order' in it. For some reason, the IntelliJ generated domain is not recognized as a valid domain class by grails.
- Added some fields to the domain class
- Generate the Controllerclass using IntelliJ (grails create-controller script is not good enough)
- Modified the 'def index = ...' into 'def scaffold = ...'
- run-app
- grails install-plugin acegi
- grails create-auth-domains User Role Requestmap
- grails generate-manager
- grails generate-registration
- grails run-app
- Create userroles : ROLE_ADMIN and ROLE_USER
- Create user: admin with ROLE_ADMIN and user with ROLE_USER
- Create mapping: i.e. /Inventory/** for ROLE_ADMIN
- grails run-app
To enable HTTPS:
basically:
- grails install-templates, ( the following code is generated from http://www.simplebits.com )
<filter>
<filter-name>Acegi Channel Processing Filter</filter-name>
<filter-class>org.springframework.security.util.FilterToBeanProxy</filter-class>
<init-param>
<param-name>targetClass</param-name>
<param-value>org.springframework.security.securechannel.ChannelProcessingFilter</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Acegi Channel Processing Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
- Navigate to the src/templates/war and add the filter to the web.xml template there:- This following code should be put into yout grails-app/conf/spring/resource.groovy file (the entire file is reproduced here):
import org.springframework.security.securechannel.ChannelProcessingFilter
import org.springframework.security.securechannel.ChannelDecisionManagerImpl
import org.springframework.security.securechannel.SecureChannelProcessor
import org.springframework.security.securechannel.InsecureChannelProcessor
// Place your Spring DSL code here
beans = {
secureChannelProcessor(SecureChannelProcessor)
insecureChannelProcessor(InsecureChannelProcessor)
channelDecisionManager(ChannelDecisionManagerImpl) {
channelProcessors = [secureChannelProcessor, insecureChannelProcessor]
}
channelProcessingFilter(ChannelProcessingFilter) {
channelDecisionManager=channelDecisionManager
filterInvocationDefinitionSource='''
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
PATTERN_TYPE_APACHE_ANT
/**=REQUIRES_SECURE_CHANNEL
'''
}
}
- grails run-app --https
Links: