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

[ENG-6820] Fix n+1 queries #201

Merged
merged 7 commits into from
Jan 10, 2025

Conversation

opaduchak
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@adlius adlius left a comment

Choose a reason for hiding this comment

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

DB query optimizations looks good. I have one concern regarding sessions and cookies.

@@ -9,6 +9,8 @@ class GVCombinedAuthentication(drf_authentication.BaseAuthentication):
"""Authentication supporting session, basic, and token methods."""

def authenticate(self, request: DrfRequest):
if request.session.get("user_reference_uri"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is a potential security problem. This session lives on gravyvalet. A sessionId cookie is set on the client side by whatever origin that hosts gravyvalet. That means when user logs out of osf.io, the sessionId cookie is not cleared on the client, nor is the session itself invalidated on the gravyvalet server side. Here's one potential scenario that could happen on staging:

  1. User logs into staging.osf.io.
  2. User makes request to gravyvalet.
  3. gravyvalet sets the sessionId cookie.
  4. User logs out of staging.osf.io.
  5. sessionId cookie is not cleared on the client side, nor is the session invalidated on gravyvalet server side.
  6. Using the same browser, an unauthenticated user successfully makes another request to gravyvalet using the old sessionId cookie.

Unless we can make sure that logging out of osf.io would also invalidated the corresponding session on the GV side, I don't think we can rely on just user_reference_uri on the session. Instead, we have to make sure the user provides the correct osf cookies for every request.

@opaduchak @brianjgeiger @aaxelb for a sanity check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed, with no way to invalidate the session, we need to rely on osf.io for maintaining that information.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would you like me to revert this change or implement session invalidation during logout?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's revert the change for this PR. If we want to implement session invalidation we can create a new ticket.

@adlius adlius merged commit 010ec19 into CenterForOpenScience:develop Jan 10, 2025
1 check passed
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 this pull request may close these issues.

3 participants