Reputation: 1010
I have a custom auth provider working against a REST API and now want to implement Remember Me functionality.
Here's what I have in Config.groovy:
grails.plugins.springsecurity.providerNames = [
'zubAuthenticationProvider',
'rememberMeAuthenticationProvider'
]
grails.plugins.springsecurity.auth.loginFormUrl="/login"
grails.plugins.springsecurity.rememberMe.cookieName="example1"
grails.plugins.springsecurity.rememberMe.key="example1"
I can't see the peristent cookie actually being set on successful login. Am I missing something in config?
** UPDATE ** I can get a cookie to be created if I add:
grails.plugins.springsecurity.rememberMe.persistent = true
But, that just leads to another problem of not using a database for login storage.
Thanks in advance, Todd
Upvotes: 3
Views: 5262
Reputation: 1010
For posterity sake, I'm going with the following--
Config.groovy
grails.plugins.springsecurity.providerNames = [
'zubAuthenticationProvider',
'rememberMeAuthenticationProvider'
]
grails.plugins.springsecurity.rememberMe.cookieName="stackoverflow"
grails.plugins.springsecurity.rememberMe.key="_grails_"
grails.plugins.springsecurity.rememberMe.rememberMe.persistent = true
conf/spring/resources.groovy
userDetailsService(com.zub.security.EgUserDetailsService) {
grailsApplication = ref('grailsApplication')
}
tokenRepository(com.zub.security.EgPersistentTokenRepository) {
grailsApplication = ref('grailsApplication')
}
def conf = SpringSecurityUtils.securityConfig
rememberMeServices(PersistentTokenBasedRememberMeServices) {
userDetailsService = ref("userDetailsService")
key = conf.rememberMe.key
cookieName = conf.rememberMe.cookieName
alwaysRemember = conf.rememberMe.alwaysRemember
tokenValiditySeconds = conf.rememberMe.tokenValiditySeconds
parameter = conf.rememberMe.parameter
useSecureCookie = conf.rememberMe.useSecureCookie // false
tokenRepository = ref('tokenRepository')
seriesLength = conf.rememberMe.persistentToken.seriesLength // 16
tokenLength = conf.rememberMe.persistentToken.tokenLength // 16
}
EgPersistentTokenRepository is based on GormPersistentTokenRepository but has been updated to make REST calls for CRUD functionality rather than GORM.
Upvotes: 3