Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aSessionRepository
orSessionRegistry
to find your session, it won't be there because you're asking for an old invalid ID. So... I addedSessionIdUpdatingHandshakeHandler
that will build you a newWebAuthenticationDetails
with your new session ID in it before releasing yourPrincipal
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 betweenQuestion
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.