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

Rename jhub-apps access_token cookie to be explicit #474

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aktech
Copy link
Member

@aktech aktech commented Sep 4, 2024

Reference Issues or PRs

At the moment the name of the cookie is access_token, which is a very generic name. It would be better to prefix it with the app it belongs to, so as to avoid confusion while development.

What does this implement/fix?

Put a x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds a feature)
  • Breaking change (fix or feature that would cause existing features not to work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Other (please describe):

Testing

  • Did you test the pull request locally?
  • Did you add new tests?

Documentation

Access-centered content checklist

Text styling

  • The content is written with plain language (where relevant).
  • If there are headers, they use the proper header tags (with only one level-one header: H1 or # in markdown).
  • All links describe where they link to (for example, check the Nebari website).
  • This content adheres to the Nebari style guides.

Non-text content

  • All content is represented as text (for example, images need alt text, and videos need captions or descriptive transcripts).
  • If there are emojis, there are not more than three in a row.
  • Don't use flashing GIFs or videos.
  • If the content were to be read as plain text, it still makes sense, and no information is missing.

Any other comments?

Copy link

vercel bot commented Sep 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jhub-apps ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 0:42am
jhub-apps-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 4, 2024 0:42am

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

This is really good, thank you! Just one question: do we need to keep reading the old cookie for one release cycle just in case to reduce disruption to existing users?

auth_by_param = APIKeyQuery(name="token", auto_error=False)

auth_by_cookie = APIKeyCookie(name="access_token")
auth_by_cookie = APIKeyCookie(name=JHUB_APPS_AUTH_COOKIE_NAME)
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about:

Suggested change
auth_by_cookie = APIKeyCookie(name=JHUB_APPS_AUTH_COOKIE_NAME)
auth_by_cookie = APIKeyCookie(name=JHUB_APPS_AUTH_COOKIE_NAME)
auth_by_cookie_deprecated = APIKeyCookie(name="access_token") # will be removed in next version

And adding or auth_by_cookie_deprecated in line 48?

Copy link
Member

Choose a reason for hiding this comment

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

In general I'm in favor of not disrupting user workflow. However this would only shift the disruption to a later date unless the user gets warned or notified in some way that they depend on deprecated behavior.

Copy link
Member

Choose a reason for hiding this comment

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

However this would only shift the disruption to a later date unless the user gets warned or notified in some way that they depend on deprecated behavior

the new cookie would be set once they log in using this version, and I think the cookies only have 7 days lifetime so think the proposed deprecation solution is fine; also the disruption would be minimal, probably just accepting the oauth screen which we are removing on nebari either way

Copy link
Member

Choose a reason for hiding this comment

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

So we are only talking about the disruption of users needing to login again once? If so, I wouldn't bother with trying to read the old one. This is just minor inconvenience and for that we need to have another PR plus review.

Copy link
Member

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks Amit! This cost me quite some time this morning until you realized that access_token was not coming from JupyterHub, but rather from here.

@@ -9,7 +9,7 @@
logger = structlog.get_logger(__name__)


def create_access_token(data: dict, expires_delta: typing.Optional[timedelta] = None):
def _create_access_token(data: dict, expires_delta: typing.Optional[timedelta] = None):
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if there is a BC policy in place, but this is BC breaking.

@@ -22,7 +22,7 @@ def create_access_token(data: dict, expires_delta: typing.Optional[timedelta] =
return encoded_jwt


def get_jhub_token_from_jwt_token(token):
def _get_jhub_token_from_jwt_token(token):
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

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