-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathShiroCasGrailsPlugin.groovy
46 lines (44 loc) · 2.17 KB
/
ShiroCasGrailsPlugin.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import grails.spring.BeanBuilder
import org.apache.shiro.cas.CasFilter
import org.apache.shiro.cas.CasSubjectFactory
import org.apache.shiro.cas.grails.ShiroCasConfigUtils
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator
class ShiroCasGrailsPlugin {
def version = "0.1.0-SNAPSHOT"
def grailsVersion = "2.0 > *"
def loadAfter = ["shiro"]
def title = "Shiro CAS Plugin"
def description = 'Enables Grails applications to use JASIG CAS for single sign-on with Apache Shiro'
def documentation = "http://grails.org/plugin/shiro-cas"
def license = "APACHE"
def developers = [
[name: "David M. Carr", email: "[email protected]"],
[name: "Ford Guo", email: "[email protected]"]
]
def organization = [ name: "CommerceHub", url: "http://www.commercehub.com/" ]
def issueManagement = [ system: "GitHub", url: "https://github.com/commercehub-oss/grails-shiro-cas/issues" ]
def scm = [ url: "https://github.com/commercehub-oss/grails-shiro-cas/" ]
def doWithSpring = {
def securityConfig = application.config.security.shiro
def beanBuilder = delegate as BeanBuilder
ShiroCasConfigUtils.initialize(application.config)
casTicketValidator(Cas20ServiceTicketValidator, ShiroCasConfigUtils.serverUrl)
casSubjectFactory(CasSubjectFactory)
def shiroSecurityManager = beanBuilder.getBeanDefinition("shiroSecurityManager")
shiroSecurityManager.propertyValues.add("subjectFactory", casSubjectFactory)
if (!securityConfig.filter.config) {
casFilter(CasFilter) {bean->
if (ShiroCasConfigUtils.failureUrl) {
failureUrl = ShiroCasConfigUtils.failureUrl
}
}
def shiroFilter = beanBuilder.getBeanDefinition("shiroFilter")
if (!securityConfig.filter.filterChainDefinitions) {
shiroFilter.propertyValues.addPropertyValue("filterChainDefinitions", ShiroCasConfigUtils.shiroCasFilter)
}
if (!securityConfig.filter.loginUrl) {
shiroFilter.propertyValues.addPropertyValue("loginUrl", ShiroCasConfigUtils.loginUrl)
}
}
}
}