Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8024871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:58:56+00:00 2026-06-04T22:58:56+00:00

Before Spring Security/MVC, I had a simple relatively insecure userobject stored in my sessions

  • 0

Before Spring Security/MVC, I had a simple relatively insecure userobject stored in my sessions that held a lot of data and that I’d update in my service logic and then store back in session with every modification.

Now I’ve successfully locked down my userobject as a Principal object with the same complex data structure. As before the userObject is available to the view after authentication with it’s initial state stored in it, but it seems my userObject implementing UserDetails is now not changeable (without creating a new Authentication Object on each request). It certainly cannot just be stashed back into the SecurityContext modified as I used to do with my session.

So I’m thinking I either need to:

A. restructure my UserObject to get all that other stuff out of there and add them to the session after authentication with a custom filter,

B. create a new authentication object after each change (sounds super expensive….)

C. some other thing that I haven’t yet seen or understood…

I’ve checked many answers and it seems a common problem, but none address my specific concerns/questions. AM I missing something really obvious here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:58:57+00:00Added an answer on June 4, 2026 at 10:58 pm

    I don’t think you’re missing anything. The intent of a UserDetails object is for it to be immutable. It’s supposed to be loaded by a UserDetailsService as part of an authentication process.

    I would vote for A: restructure your user object and put as little in the session as possible. Really the user object should only be storing the authorities relevant to your application, and possibly user attributes that don’t change very much (name, title, etc.) and only if the application needs them for display or processing purposes. It should not be storing data you’re accumulating as the user uses the application (tracking habits, clicks, etc.). That should be stored elsewhere, such as in a database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we're using Spring MVC with Spring security. One of the requirements is that if
I'm doing some proof-of-concept work with Spring MVC and security. So far I've managed
I have a web application that uses spring security. It uses <intercept-url ../> elements
I'm using Spring Security which works great to make sure that a user has
Have simple Spring Security webapp with password encoding: <security:authentication-manager alias=authenticationManager> <security:authentication-provider user-service-ref=personService> <security:password-encoder hash=md5
I have been in the process of upgrading a Spring MVC app that was
Currently I have a custom form login page in Spring Security 3 that sends
I've got a web app that uses spring security. I'm wanting to redirect the
I have an existing grails application that uses spring-security plugin for authentication. I would
I wonder if, with Spring Security, I can validate the user sessions, allowing only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.