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

Island: Add token type into token payload #3183

Closed
wants to merge 17 commits into from
Closed

Conversation

VakarisZ
Copy link
Contributor

@VakarisZ VakarisZ commented Mar 31, 2023

Token type will make sure that access tokens can't get validated for refresh tokens and vice-versa

What does this PR do?

Fixes part of #3137.

Add any further explanations here.

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?
  • Have you checked that you haven't introduced any duplicate code?

Testing Checklist

  • Added relevant unit tests?
  • Do all unit tests pass?
  • Do all end-to-end tests pass?
  • Any other testing performed?

    Tested by {Running the Monkey locally with relevant config/running Island/...}

  • If applicable, add screenshots or log transcripts of the feature working

VakarisZ and others added 17 commits March 31, 2023 11:00
If a new refresh token is generated, even if the old token isn't expired yet,
the new one should be invalidated. We shouldn't have two valid refresh tokens
for a user.
We don't revoke old refresh tokens because they expire automatically
The key should be the same in requests and responses, it's best to have a constant for it
Co-authored-by: VakarisZ <36815064+VakarisZ@users.noreply.github.com>
Extracting token owner code and explicit validation better conveys the logic
This method checks for island api user registration, not registered agents. Also, authentication_facade.py shouldn't be coupled to mongodb syntax
Token type will make sure that access tokens can't get validated for refresh tokens and vice-versa
Comment on lines 65 to 66
self._refresh_token_validator.validate_token(refresh_token, token_type=TokenType.REFRESH)
user_uniquifier = self._refresh_token_validator.get_token_payload(refresh_token)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This becomes a bit dangerous, because the user needs to call validate first. We could include the validation into payload retrieval. In that case, we should merge the TokenValidator and TokenGenerator into the TokenSerializer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mssalvatore mssalvatore force-pushed the 3137-new-token-pair-endpoint branch from 315c23c to a2ce7d3 Compare April 3, 2023 15:39
Base automatically changed from 3137-new-token-pair-endpoint to develop April 3, 2023 15:41
@mssalvatore
Copy link
Collaborator

We went a different direction.

@mssalvatore
Copy link
Collaborator

We went a different direction.

@mssalvatore mssalvatore deleted the 3137-token-types branch April 10, 2023 17:22
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.

4 participants