Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove InMemoryUserRepository #6

Merged
merged 2 commits into from
Nov 10, 2022
Merged

remove InMemoryUserRepository #6

merged 2 commits into from
Nov 10, 2022

Conversation

scionaltera
Copy link
Owner

Removed the hacky InMemoryUserRepository in favor of attributes in your HTTP session, which opened up a whole different can of worms.

I found a bug where Spring Security and Spring Session and Spring Websocket don't play well together.

Spring Security rotates your HTTP session ID after you authenticate, but your Principal still has your old session ID. So when you go to use a SessionRepository or SessionRegistry to find your session, it won't be there because you're asking for an old invalid ID. So... I added SessionIdUpdatingHandshakeHandler that will build you a new WebAuthenticationDetails with your new session ID in it before releasing your Principal into the wild. Now the session IDs all match up and everybody's happy.

We're back to using the original Principal with the "loginwithamazonblahblahblah" name instead of session IDs now too. The names are the same but the HTTP session IDs are different and of course the WebSocket session names are different too, so we can still tell multiple browsers apart and avoid accidentally broadcasting messages to both.

Fixed the short session timeout to 24 hours.

Refactored Question so it's aware of its bean name. We move between Question instances by bean name which means they can be singletons but they do need to be stateless. I think that's OK. If it isn't we can try something fancier like session scoped beans and see where that takes us.

@scionaltera scionaltera merged commit 4c64ae9 into master Nov 10, 2022
@scionaltera scionaltera deleted the session-fixup branch November 10, 2022 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant