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

feat: Rewrite of session-based securitykeys #764

Merged
merged 13 commits into from
Jun 27, 2023

Conversation

phorward
Copy link
Member

@phorward phorward commented Jun 12, 2023

This is a draft for solving the problem of one session-based securitykey, making multiple requests in parallel impossible. This pull request partly replaces #704.

Features:

  • a new securitykey is created every time it is requested
  • securitykeys are bound to a session, if session-flag is True (default)
  • unused securitykeys from a session are either being dropped on session kill, or when they became invalid
  • Entire code refactoring for both securitykey and session module
  • /json/skey' accepts amount`-flag for batch-mode skey requesting (decreases amount of requests)

This is a draft for solving the problem of one session-based securitykey, making multiple requests in parallel impossible.

- a new securitykey is created every time it is requested
- securitykeys are bound to a session, if `session`-flag is True (default)
- unused securitykeys from a session are either being dropped by session or when they became invalid
- Entire code refactoring for both securitykey and session module
- This pull request partly replaces viur-framework#704
Copy link
Contributor

@ArneGudermann ArneGudermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @phorward thank you for this PR. I have a littel suggetion. Can you please take a look.

core/session.py Outdated Show resolved Hide resolved
core/session.py Outdated Show resolved Hide resolved
core/session.py Outdated Show resolved Hide resolved
phorward and others added 2 commits June 13, 2023 15:01
Co-authored-by: agudermann <47318461+ArneGudermann@users.noreply.github.com>
core/render/json/__init__.py Outdated Show resolved Hide resolved
core/securitykey.py Outdated Show resolved Hide resolved
return True

elif session.validateSecurityKey(key):
if session and key == "staticSessionKey":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please introduce a constant for this?
e.g.

STATIC_KEY = "staticSessionKey"

(without "session", bc if you do import session from viur.core and do session.STATIC_KEY, "session" would be redundant otherwise)

Suggested change
if session and key == "staticSessionKey":
if session and key == STATIC_KEY:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0bfc59e cleans up the use of the static session key and its naming.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But things got mixed up here.

SECURITYKEY_STATIC now contains the header name. The static key for the session skey, which was previously "staticSessionKey", is now also the header name "Sec-X-ViUR-StaticSessionKey". This is btw. a breaking change...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, and who uses it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created #796

core/session.py Outdated Show resolved Hide resolved
core/session.py Show resolved Hide resolved
core/securitykey.py Outdated Show resolved Hide resolved
@phorward phorward requested a review from sveneberth June 19, 2023 21:18
@phorward phorward added feature New feature or request Priority: High After critical issues are fixed, these should be dealt with before any further issues. refactoring Pull requests that refactor code but do not change its behavior. viur-meeting Issues to discuss in the next ViUR meeting labels Jun 19, 2023
- removed duration flag
- added amount flag
- batch-mode only possible for authenticated users
@phorward phorward removed the viur-meeting Issues to discuss in the next ViUR meeting label Jun 23, 2023
@phorward phorward merged commit 6cc4273 into viur-framework:develop Jun 27, 2023
@phorward phorward deleted the feat-securitykey.rewrite branch September 12, 2023 15:23
sveneberth added a commit to sveneberth/viur-core that referenced this pull request Nov 26, 2023
phorward pushed a commit that referenced this pull request Dec 8, 2023
Resolve #796 as follow-up of #764

Before #764 the marker was `staticSessionKey`, but that wasn't PEP8. And
since that has already been changed, I am using a new name, which IMO is
better understood as a constant marker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request Priority: High After critical issues are fixed, these should be dealt with before any further issues. refactoring Pull requests that refactor code but do not change its behavior.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants