Skip to content

Possibilty to pass in a existing session #404

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

Closed
thorstenfleischmann opened this issue Nov 4, 2021 · 1 comment · Fixed by #405
Closed

Possibilty to pass in a existing session #404

thorstenfleischmann opened this issue Nov 4, 2021 · 1 comment · Fixed by #405

Comments

@thorstenfleischmann
Copy link
Contributor

I am missing an option to pass in an existing session.

This would solve three issues for me:

  1. I also use the session to do some stuff (i.E. csrf-checks). Sometimes I'd like to operate on the session before calling authenticate.

  2. authenticate() always creates a new session if the session-cookie could not be opened (session.start vs session.open). I want to be able to detect if an existing session could not be opened i.E. because of a invalid signature (wrong session secret).

  3. If the access token refresh is executed a new cookie will be generated (session.regenerate). This can cause issues if there are multiple requests from the same user which require a token refresh:

Request 1 with existing session 'A': refreshes access token, regenerate creates a new (authenticated) session 'B'
Request 2 with existing session 'A': refresh is already done, session 'A' is unknown. because of session.start() this will also create a new (unauthenticated) session 'C'
Request 3: will use the last cookie which most likely will be session 'C' (unauthenticated).

This issue can not be solved within this library because - by design - the library can not know if a new session should be created (session.start) or an existing one should be used (session.open). However in my use case I know exactly which locations should create a new session and which locations should not.

All three issues can be "workarounded" by opening and closing the session twice (in my code before authenticate and in authenticate). But with a session database and locking mechanisms this seems inefficient.

Therefore I think it would be awesome to have an option to pass in an existing session.

@thorstenfleischmann
Copy link
Contributor Author

Another solution might be to use session.open() if unauth_action is "deny". But I dont know which regressions this could introduce and it seems a bit implicit

thorstenfleischmann added a commit to thorstenfleischmann/lua-resty-openidc that referenced this issue Nov 4, 2021
bodewig added a commit that referenced this issue Nov 6, 2021
…ss-in-a-existing-session

#404 Possibilty to pass in a existing session
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 a pull request may close this issue.

1 participant