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

Provide Session Id Generation Strategy #11

Closed
rwinch opened this issue Jul 3, 2014 · 7 comments
Closed

Provide Session Id Generation Strategy #11

rwinch opened this issue Jul 3, 2014 · 7 comments
Assignees
Labels
in: core type: enhancement A general enhancement

Comments

@rwinch
Copy link
Member

rwinch commented Jul 3, 2014

We are currently using UIDs for session id generation. It may be better to include other characters to increase the entropy. We should be careful in how we use SecureRandom See https://www.synopsys.com/blogs/software-security/proper-use-of-javas-securerandom/ Last, we may want to make generating ids a strategy interface so that users can swap this out

@artgramlich
Copy link

+1
Thanks for closing the other issue, somehow I didn't see this issue.

@artgramlich
Copy link

I submitted a pull request #204.

@rwinch rwinch changed the title Update Session Id Generation Provide Session Id Generation Strategy Nov 5, 2015
@rwinch rwinch added this to the 1.1.0 M1 milestone Nov 5, 2015
@rwinch rwinch modified the milestones: 1.1.0 RC1, 1.1.0 M1 Nov 11, 2015
@derylspielman
Copy link

This would be very helpful so that we can customize the session ID with a suffix of the jvmRoute. We have legacy code that requires the .jvmRoute at the end and currently calling httpRequest.getSession().getId()
comes without the jvmRoute. Any progress on this?

@abhishekjoy1
Copy link

abhishekjoy1 commented Jul 15, 2020

Hi, I am trying to overwrite the UUID generated as part of MapSession as there is a potential risk involved with this (https://neilmadden.blog/2018/08/30/moving-away-from-uuids/).

To mitigate this risk, I am trying to overwrite the session-id generated through framework as follows taking the idea from (https://stackoverflow.com/questions/48353967/how-to-modify-or-custom-sessionid-in-spring-session-project):

`
@EnableSpringHttpSession
public class CustomSessionRepository implements SessionRepository {

        private Integer defaultMaxInactiveInterval;
        private  Map<String, Session> sessions = new ConcurrentHashMap<>();

        public CustomSessionRepository() {
             this.sessions = sessions;
        }

        public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) {
             this.defaultMaxInactiveInterval = defaultMaxInactiveInterval;
        }
   
        public void save(MapSession session) {
            if (!session.getId().equals(session.getOriginalId())) {
                this.sessions.remove(session.getOriginalId());
           }

          this.sessions.put(session.getId(), new MapSession(session));
        }

        public MapSession findById(String id) {
             Session saved = (Session)this.sessions.get(id);
             if (saved == null) {
                 return null;
             } else if (saved.isExpired()) {
                  this.deleteById(saved.getId());
                  return null;
             } else {
                 return new MapSession(saved);
             }
        }

        public void deleteById(String id) {
            this.sessions.remove(id);
        }

       public MapSession createSession() {
           MapSession result = new MapSession(myCustomId());
           if (this.defaultMaxInactiveInterval != null) {
              result.setMaxInactiveInterval(Duration.ofSeconds((long)this.defaultMaxInactiveInterval));
         }

       return result;
     }
   }

`

But this is not working. Now the session is not getting persisted to Redis. I cannot understand what I am missing here.

In this context, I have gone through this: #1406, but did not get a concrete idea. I have posted a question in SO also in this regard: https://stackoverflow.com/questions/62897170/how-to-instantiate-org-springframework-session-mapsession-in-my-spring-boot-appl

Could anyone please help me to fix this? Thanks.

@PvanHengel
Copy link

Hi where do we stand on this enhancement, our security team feels that the session ids being generated are not random enough (eg long enough), and would like a way to modify it. Does anyone know if there is an alternative and/or how we can get this PR updated and merged in?

@rwinch rwinch removed this from the General Backlog milestone Nov 15, 2022
@marcusdacoregio marcusdacoregio self-assigned this Jan 26, 2023
quaff added a commit to quaff/spring-session that referenced this issue Feb 23, 2023
quaff added a commit to quaff/spring-session that referenced this issue Feb 23, 2023
quaff added a commit to quaff/spring-session that referenced this issue Feb 23, 2023
quaff added a commit to quaff/spring-session that referenced this issue Feb 23, 2023
quaff added a commit to quaff/spring-session that referenced this issue Feb 23, 2023
quaff added a commit to quaff/spring-session that referenced this issue Feb 24, 2023
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Mar 7, 2023
@marcusdacoregio marcusdacoregio added this to the 3.1.0-M1 milestone Mar 7, 2023
quaff added a commit to quaff/spring-session that referenced this issue Mar 13, 2023
quaff added a commit to quaff/spring-session that referenced this issue Mar 13, 2023
@marcusdacoregio marcusdacoregio modified the milestones: 3.1.0-M1, 3.1.0-M2 Mar 21, 2023
@marcusdacoregio
Copy link
Collaborator

Hi @PvanHengel, I am planning on getting this done for the 3.1 release.

marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Apr 5, 2023
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Apr 5, 2023
@marcusdacoregio marcusdacoregio removed this from the 3.1.0-RC1 milestone Apr 18, 2023
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Apr 18, 2023
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jun 12, 2023
@marcusdacoregio
Copy link
Collaborator

Closing in favor of #2286

marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 3, 2023
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 11, 2023
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 11, 2023
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 12, 2023
marcusdacoregio added a commit to marcusdacoregio/spring-session that referenced this issue Jul 12, 2023
marcusdacoregio added a commit that referenced this issue Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: enhancement A general enhancement
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

7 participants