apache / apache/grails-core

sessionRegistry get erased upon Grails fast reload

Open
#15,882 0 comments 0 reactions 0 assignees View on GitHub
relates-to:spring-security
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

In a Grails 4 webapp with Spring Security plugin dependency

org.grails.plugins:spring-security-core:4.0.0.RC2

in any controller inject dependencies

def springSecurityService
def sessionRegistry

and include this snippet in an action `A`:

println 'principal: ' + springSecurityService.principal?.username
println 'currentUser: ' + springSecurityService.currentUser
println '-------------'
println 'principal sessions: ' + sessionRegistry.getAllSessions(springSecurityService.principal, true)
println 'all principals: ' + sessionRegistry.allPrincipals.collect { it.username }

### Steps to Reproduce

1. run webapp
2. login with valid credentials
3. execute action `A`
4. trigger a fast reload (Spring Dev Tools)
5. execute action `A` again

### Expected Behaviour

Both snippets should print

principal: user@domain.com
currentUser: UserDomainClass(email:user@domain.com)
-------------
principal sessions: [org.springframework.security.core.session.SessionInformation@644c9f8a]
all principals: [user@domain.com]

### Actual Behaviour

2nd execution shows session registry being erased, while principal is maintained as expected

principal: user@domain.com
currentUser: UserDomainClass(email:user@domain.com)
-------------
principal sessions: []
all principals: []

### Environment Information

- **Operating System**: macOS Mojave (10.14.6)
- **GORM Version:** 7.0.0
- **Grails Version (if using Grails):** 4.0.1
- **JDK Version:** 1.8.0_60

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in a Grails 4.0.1 webapp using spring-security-core 4.0.0.RC2 and Spring Dev Tools, following the listed login and fast-reload steps. Compare sessionRegistry output before and after reload; done means the principal sessions and all principals remain available after the reload.

Written by the indexing model from the issue text.

Assessment

Tech stack
spring
Domain
authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.