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

Add frontend for JWT refresh tokens #3273

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

stveit
Copy link
Contributor

@stveit stveit commented Feb 6, 2025

Adds a frontend for managing JWT refresh tokens. You can see which tokens exist, expire existing ones and generate new ones.

A quirk of allowing the users to expire the token by setting the expiry date to be now, is that there will be a mismatch between the expiry timestamp in the token itself, and the expiry date in the database. Basically, the database timestamps decide if the token is active or not, not the claims in the token itself. In practice, I dont think this detail matters much, but a different approach could be to instead allow users to "Revoke" a token, setting an extra flag that marks the token as revoked without touching the expiry date itself. End result is that the db decides if its active or not either way, which is what we want so there actually is a way to revoke tokens.

Thoughts?

Copy link

github-actions bot commented Feb 6, 2025

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON black 9 0 0.87s
✅ PYTHON ruff 9 0 0.01s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link

github-actions bot commented Feb 6, 2025

Test results

    9 files      9 suites   8m 26s ⏱️
2 178 tests 2 178 ✅ 0 💤 0 ❌
4 095 runs  4 095 ✅ 0 💤 0 ❌

Results for commit 80d6175.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.59%. Comparing base (dbf3893) to head (80d6175).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3273      +/-   ##
==========================================
+ Coverage   60.58%   60.59%   +0.01%     
==========================================
  Files         606      606              
  Lines       43733    43868     +135     
  Branches       48       48              
==========================================
+ Hits        26494    26582      +88     
- Misses      17227    17274      +47     
  Partials       12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stveit stveit force-pushed the jwt-refresh-token-frontend branch from f33e025 to 38ae35e Compare February 6, 2025 08:02
@stveit stveit force-pushed the jwt-refresh-token-frontend branch from 38ae35e to 80d6175 Compare February 6, 2025 08:27
@pytest.fixture(scope="module")
def private_key() -> str:
"""Yields a private key in PEM format"""
key = """-----BEGIN PRIVATE KEY-----

Check failure

Code scanning / SonarCloud

Cryptographic private keys should not be disclosed High test

Make sure this private key gets revoked, changed, and removed from the code. See more on SonarQube Cloud
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dummy key. But a more relevant point is that there are already tests that define PEM keys, so instead of redefining keys here its probably better to restructure the fixtures to allow this test file access to those fixtures

Copy link

sonarqubecloud bot commented Feb 6, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
12.8% Duplication on New Code (required ≤ 3%)
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant