Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 331 lines (282 sloc) 9.441 kb
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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
/* Copyright 2006-2014 SpringSource.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import grails.plugin.springsecurity.SecurityConfigType
import grails.plugin.springsecurity.SpringSecurityUtils
import grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken

import org.springframework.security.authentication.RememberMeAuthenticationToken
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices
import org.springframework.security.web.authentication.rememberme.PersistentTokenBasedRememberMeServices
import org.springframework.security.web.authentication.switchuser.SwitchUserFilter
import org.springframework.security.web.context.HttpSessionSecurityContextRepository

security {

/** misc properties */

active = true

printStatusMessages = true

ajaxHeader = 'X-Requested-With'
ajaxCheckClosure = null

registerLoggerListener = false

// 'strict' mode where an explicit grant is required to access any resource;
// if true make sure to allow IS_AUTHENTICATED_ANONYMOUSLY or permitAll
// for /, /index.gsp, /js/**, /css/**, /images/**, /login/**, /logout/**, etc.
// Also consider using fii.rejectPublicInvocations = true
rejectIfNoRule = true

// hierarchical roles
roleHierarchy = ''

// ip restriction filter
ipRestrictions = [:]

// voters
voterNames = [] // 'authenticatedVoter', 'roleVoter', 'closureVoter'

// providers
providerNames = [] // 'daoAuthenticationProvider', 'anonymousAuthenticationProvider', 'rememberMeAuthenticationProvider'

// AfterInvocationManager
afterInvocationManagerProviderNames = []

// HttpSessionEventPublisher
useHttpSessionEventPublisher = false

// SecurityEventListener
useSecurityEventListener = false

// user caching
cacheUsers = false

// user and role class properties
userLookup {
userDomainClassName = null // must be set if using UserDetailsService
usernamePropertyName = 'username'
enabledPropertyName = 'enabled'
passwordPropertyName = 'password'
authoritiesPropertyName = 'authorities'
accountExpiredPropertyName = 'accountExpired'
accountLockedPropertyName = 'accountLocked'
passwordExpiredPropertyName = 'passwordExpired'
authorityJoinClassName = null // must be set if using UserDetailsService
}
authority {
className = null // must be set if using UserDetailsService
nameField = 'authority'
groupAuthorityNameField = null //must be set if using authority groups
}
useRoleGroups = false

/** authenticationProcessingFilter */
apf {
filterProcessesUrl = '/j_spring_security_check'
usernameParameter = UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY // 'j_username'
passwordParameter = UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY // 'j_password'
continueChainBeforeSuccessfulAuthentication = false
allowSessionCreation = true
postOnly = true
storeLastUsername = false
}

// authenticationFailureHandler
failureHandler {
defaultFailureUrl = '/login/authfail?login_error=1'
ajaxAuthFailUrl = '/login/authfail?ajax=true'
exceptionMappings = [:]
useForward = false
allowSessionCreation = true
}

// successHandler
successHandler {
defaultTargetUrl = '/'
alwaysUseDefault = false
targetUrlParameter = SpringSecurityUtils.DEFAULT_TARGET_PARAMETER // 'spring-security-redirect'
ajaxSuccessUrl = '/login/ajaxSuccess'
useReferer = false
}

// requestCache
requestCache {
createSession = true
}

// redirectStrategy
redirectStrategy {
contextRelative = false
}

// session fixation prevention
useSessionFixationPrevention = true
sessionFixationPrevention {
migrate = true
alwaysCreateSession = false
}

/** daoAuthenticationProvider **/
dao {
reflectionSaltSourceProperty = null // if null, don't use salt source
hideUserNotFoundExceptions = true
}

/** anonymousProcessingFilter */
anon {
key = 'foo'
}

/** authenticationEntryPoint */
auth {
loginFormUrl = '/login/auth'
forceHttps = false
ajaxLoginFormUrl = '/login/authAjax'
useForward = false // redirect to login page
}

/** logoutFilter */
logout {
afterLogoutUrl = '/'
filterProcessesUrl = '/j_spring_security_logout'
handlerNames = [] // 'rememberMeServices', 'securityContextLogoutHandler'
clearAuthentication = true
invalidateHttpSession = true
targetUrlParameter = null
alwaysUseDefaultTargetUrl = false
redirectToReferer = false
postOnly = true
}

/**
* accessDeniedHandler
* set errorPage to null to send Error 403 instead of showing error page
*/
adh {
errorPage = '/login/denied'
ajaxErrorPage = '/login/ajaxDenied'
useForward = true
}

/** passwordEncoder */
// see http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html
password {
algorithm = 'bcrypt'
encodeHashAsBase64 = false
bcrypt {
logrounds = 10
}
hash {
iterations = 10000
}
}

/** rememberMeServices */
rememberMe {
cookieName = 'grails_remember_me'
alwaysRemember = false
tokenValiditySeconds = AbstractRememberMeServices.TWO_WEEKS_S // 1209600 -> 14 days
parameter = AbstractRememberMeServices.DEFAULT_PARAMETER // '_spring_security_remember_me'
key = 'grailsRocks'
persistent = false
persistentToken {
domainClassName = null
seriesLength = PersistentTokenBasedRememberMeServices.DEFAULT_SERIES_LENGTH // 16
tokenLength = PersistentTokenBasedRememberMeServices.DEFAULT_TOKEN_LENGTH // 16
}
useSecureCookie = null
createSessionOnSuccess = true
}

/** URL <-> Role mapping */

// default to annotation mode
securityConfigType = SecurityConfigType.Annotation

// use Requestmap domain class to store rules in the database
// change securityConfigType to 'Requestmap'
requestMap {
className = null // must be set if using
urlField = 'url'
configAttributeField = 'configAttribute'
httpMethodField = 'httpMethod'
}

// use annotations from Controllers to define security rules
// change securityConfigType to 'Annotation'
controllerAnnotations {
staticRules = [:]
}

// use a Map of URL -> roles to define security rules
// or List of Maps where the keys are pattern (URL pattern),
// access (single token or List, e.g. role name(s)), httpMethod (optional restriction to particular method)
// to use, change securityConfigType to 'InterceptUrlMap'
interceptUrlMap = null

/** basic auth */
useBasicAuth = false
basic {
realmName = 'Grails Realm'
credentialsCharset = 'UTF-8'
}

/** digest auth */
useDigestAuth = false
digest {
realmName = 'Grails Realm'
key = 'changeme'
nonceValiditySeconds = 300
passwordAlreadyEncoded = false
createAuthenticatedToken = false
useCleartextPasswords = false
}

/** use switchUserProcessingFilter */
useSwitchUserFilter = false
switchUser {
switchUserUrl = '/j_spring_security_switch_user'
exitUserUrl = '/j_spring_security_exit_user'
targetUrl = null // use the authenticationSuccessHandler
switchFailureUrl = null // use the authenticationFailureHandler
usernameParameter = SwitchUserFilter.SPRING_SECURITY_SWITCH_USERNAME_KEY // j_username
}

// port mappings
portMapper {
httpPort = 8080
httpsPort = 8443
}

// secure channel filter (http/https)
secureChannel {
definition = [:]
useHeaderCheckChannelSecurity = false
secureHeaderName = 'X-Forwarded-Proto'
secureHeaderValue = 'http'
insecureHeaderName = 'X-Forwarded-Proto'
insecureHeaderValue = 'https'
}

// X509
useX509 = false
x509 {
continueFilterChainOnUnsuccessfulAuthentication = true
subjectDnRegex = 'CN=(.*?)(?:,|$)'
subjectDnClosure = null
checkForPrincipalChanges = false
invalidateSessionOnPrincipalChange = true
throwExceptionWhenTokenRejected = false
}

// authenticationTrustResolver
atr {
anonymousClass = GrailsAnonymousAuthenticationToken
rememberMeClass = RememberMeAuthenticationToken
}

// providerManager
providerManager {
eraseCredentialsAfterAuthentication = true
}

// securityContextRepository
scr {
allowSessionCreation = true
disableUrlRewriting = true
springSecurityContextKey = HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY // 'SPRING_SECURITY_CONTEXT'
}

// securityContextPersistenceFilter
scpf {
forceEagerSessionCreation = false
}

// filterInvocationInterceptor
fii {
alwaysReauthenticate = false
rejectPublicInvocations = true
validateConfigAttributes = true
publishAuthorizationSuccess = false
observeOncePerRequest = true
}

debug {
useFilter = false
}

// SecurityContextHolder
sch {
// one of MODE_THREADLOCAL, MODE_INHERITABLETHREADLOCAL, MODE_GLOBAL,
// or the name of a class implementing org.springframework.security.core.context.SecurityContextHolderStrategy
strategyName = SecurityContextHolder.MODE_THREADLOCAL
}
}
Something went wrong with that request. Please try again.