-
Notifications
You must be signed in to change notification settings - Fork 4
/
AlaWebThemeGrailsPlugin.groovy
235 lines (207 loc) · 8.94 KB
/
AlaWebThemeGrailsPlugin.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
import au.org.ala.web.SecurityPrimitives
import grails.util.Environment
import grails.util.Holders
class AlaWebThemeGrailsPlugin {
// the plugin version
def version = "0.8.8-SNAPSHOT"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "2.1 > *"
// the other plugins this plugin depends on
def dependsOn = [:]
// resources that are excluded from plugin packaging
def pluginExcludes = ["grails-app/views/error.gsp"]
def title = "Ala Web Theme Plugin" // Headline display name of the plugin
def author = "Nick dos Remedios"
def authorEmail = "[email protected]"
def description = '''\
This plugin provides a Sitemesh layout file (main.gsp) and associated resources files, based on Bootstrap.
It also provides a taglib for the ALA footer and navigation menu, login/logout links and a logout controller,
that invalidates the session. CSS files are generated from the Bootstrap LESS files, so any changes should be
made to `ala.less` and then CSS files generated with provided script (see README.md).
'''
// URL to the plugin's documentation
def documentation = "http://code.google.com/p/ala/wiki/AlaWebTheme"
// License: one of 'APACHE', 'GPL2', 'GPL3'
def license = "MPL2"
// Details of company behind the plugin (if there is one)
def organization = [ name: "Atlas of Living Australia", url: "http://www.ala.org.au/" ]
// Any additional developers beyond the author specified above.
def developers = [ [ name: "Nick dos Remedios", email: "[email protected]" ], [ name: "Dave Martin", email: "[email protected]" ]]
// Location of the plugin's issue tracker.
def issueManagement = [ system: "github", url: "https://github.com/AtlasOfLivingAustralia/ala-web-theme/issues" ]
// Online location of the plugin's browseable source code.
def scm = [ url: "https://github.com/AtlasOfLivingAustralia/ala-web-theme" ]
// Note: ONLY evaluated at compile time (not run time)
def doWithWebDescriptor = { xml ->
def mappingElement = xml.'context-param'
def lastMapping = mappingElement[mappingElement.size()-1]
String defaultConfig = Holders.config.default_config
if (Holders.config.runWithNoExternalConfig == true) {
// No external config file set, use security.cas.* settings embedded un web.xml instead
if (!Holders.config.security.cas || Holders.config.security.cas.size() == 0) {
println "No security.cas.* settings found (or external conf found) - setting bypass = true"
Holders.config.security.cas.bypass = true
}
lastMapping + {
'context-param' {
'param-name' ('serverName')
'param-value' (Holders.config.security.cas.appServerName)
}
'context-param' {
'param-name' ('casServerName')
'param-value' (Holders.config.security.cas.casServerName)
}
'context-param' {
'param-name' ('uriFilterPattern')
'param-value' (Holders.config.security.cas.uriFilterPattern)
}
'context-param' {
'param-name' ('uriExclusionFilterPattern')
'param-value' (Holders.config.security.cas.uriExclusionFilterPattern)
}
'context-param' {
'param-name' ('authenticateOnlyIfLoggedInFilterPattern')
'param-value' (Holders.config.security.cas.authenticateOnlyIfLoggedInPattern)
}
}
if (Holders.config.security.cas.contextPath) {
lastMapping + {
'context-param' {
'param-name' ('contextPath')
'param-value' (Holders.config.security.cas.contextPath)
}
}
}
} else {
// Use `configPropFile` external config which is read by ala-cas-client-2.0-SNAPSHOT.jar
lastMapping + {
'env-entry' {
'env-entry-name' ('configPropFile')
'env-entry-value' (defaultConfig)
'env-entry-type' ('java.lang.String')
}
}
}
mappingElement = xml.'filter'
lastMapping = mappingElement[mappingElement.size()-1]
lastMapping + {
'filter' {
'filter-name' ('CAS Single Sign Out Filter')
'filter-class' ('org.jasig.cas.client.session.SingleSignOutFilter')
}
'filter' {
'filter-name' ('CAS Authentication Filter')
'filter-class' ('au.org.ala.cas.client.UriFilter')
'init-param' {
'param-name' ('filterClass')
'param-value' ('org.jasig.cas.client.authentication.AuthenticationFilter')
}
'init-param' {
'param-name' ('casServerLoginUrl')
'param-value' (Holders.config.security.cas.loginUrl)
}
'init-param' {
'param-name' ('gateway')
'param-value' ('false')
}
'init-param' {
'param-name' ('disableCAS')
'param-value' (Holders.config.security.cas.bypass as Boolean == true ? 'true' : 'false')
}
}
'filter' {
'filter-name' ('CAS Validation Filter')
'filter-class' ('au.org.ala.cas.client.UriFilter')
'init-param' {
'param-name' ('filterClass')
'param-value' ('org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter')
}
'init-param' {
'param-name' ('disableCAS')
'param-value' (Holders.config.security.cas.bypass as Boolean == true ? 'true' : 'false')
}
'init-param' {
'param-name' ('casServerUrlPrefix')
'param-value' (Holders.config.security.cas.casServerUrlPrefix)
}
}
'filter' {
'filter-name' ('CAS HttpServletRequest Wrapper Filter')
'filter-class' ('au.org.ala.cas.client.UriFilter')
'init-param' {
'param-name' ('filterClass')
'param-value' ('au.org.ala.cas.client.AlaHttpServletRequestWrapperFilter')
}
'init-param' {
'param-name' ('disableCAS')
'param-value' (Holders.config.security.cas.bypass as Boolean == true ? 'true' : 'false')
}
}
'filter-mapping' {
'filter-name' ('CAS Single Sign Out Filter')
'url-pattern' ('/*')
}
'filter-mapping' {
'filter-name' ('CAS Authentication Filter')
'url-pattern' ('/*')
}
'filter-mapping' {
'filter-name' ('CAS Validation Filter')
'url-pattern' ('/*')
}
'filter-mapping' {
'filter-name' ('CAS HttpServletRequest Wrapper Filter')
'url-pattern' ('/*')
}
}
if (Holders.config.security.cas.debugWebXml) {
println "web.xml = ${mappingElement}"
}
}
def doWithSpring = {
//System.println("Merging conf...")
//mergeConfig(application)
def config = application.config
if (!config.userDetails.url) {
config.userDetails.url = "http://auth.ala.org.au/userdetails/userDetails/"
}
if (!config.userDetails.path) {
config.userDetails.path = "getUserListFull"
}
if (!config.userDetailsById.path) {
config.userDetailsById.path = "getUserDetails"
}
if (!config.userDetailsById.bulkPath) {
config.userDetailsById.bulkPath = 'getUserDetailsFromIdList'
}
if (!config.grails.cache.config) {
config.grails.cache.config = {
defaults {
eternal false
overflowToDisk false
maxElementsInMemory 20000
timeToLiveSeconds 3600
}
cache {
name 'userListCache'
}
cache {
name 'userMapCache'
}
}
}
securityPrimitives(SecurityPrimitives) { beanDefinition ->
beanDefinition.constructorArgs = [ref('authService'), ref('grailsApplication')]
}
}
def doWithDynamicMethods = { ctx ->
}
def doWithApplicationContext = { applicationContext ->
}
def onChange = { event ->
}
def onConfigChange = { event ->
}
def onShutdown = { event ->
}
}