Skip to content

core: add user settable token durations - #7410

Merged
BeryJu merged 28 commits into
goauthentik:mainfrom
jmdilly:access_token
Apr 11, 2024
Merged

BeryJu merged 28 commits into
goauthentik:mainfrom
jmdilly:access_token

Conversation

@jmdilly

@jmdilly jmdilly commented Nov 2, 2023

Copy link
Copy Markdown
Contributor

Details

This PR enables users to specify a non default lifetime for users created app application token. By the way, it enforces expires value on API side.

Closes #5881

Current limitation : maximum duration is currently not enforce in the UI but only on API side. This is because I haven't find yet an easy way to provide that piece of information to the UI without add a new API endpoint which would require additionnal work. Nevertheless, if the chosen expiration date is invalid, an error message is still thrown up to the use explaining why it has failed.
In my opinion, this enforcement within the UI could be enforced in a future improvement.


Checklist

  • Local tests pass (ak test authentik/)
  • The code has been formatted (make lint-fix)

If an API change has been made

  • [] The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • The code has been formatted (make web)
  • The translation files have been updated (make i18n-extract)

If applicable

  • The documentation has been updated
  • The documentation has been formatted (make website)

@jmdilly
jmdilly requested review from a team as code owners November 2, 2023 02:15
@netlify

netlify Bot commented Nov 2, 2023 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit 12736d0
🔍 Latest deploy log https://app.netlify.com/sites/authentik-storybook/deploys/6616ab95f08f34000880de1f
😎 Deploy Preview https://deploy-preview-7410--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov

codecov Bot commented Nov 2, 2023 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 31.03448% with 60 lines in your changes are missing coverage. Please review.

Project coverage is 45.89%. Comparing base (633028c) to head (12736d0).

Files Patch % Lines
authentik/core/tests/test_token_api.py 0.00% 42 Missing ⚠️
authentik/core/api/tokens.py 13.33% 13 Missing ⚠️
authentik/core/models.py 75.00% 4 Missing ⚠️
authentik/core/signals.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7410       +/-   ##
===========================================
- Coverage   92.40%   45.89%   -46.51%     
===========================================
  Files         646      646               
  Lines       31851    31926       +75     
===========================================
- Hits        29431    14654    -14777     
- Misses       2420    17272    +14852     
Flag Coverage Δ
e2e 44.38% <31.03%> (-6.13%) ⬇️
integration 26.33% <27.58%> (-0.02%) ⬇️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@netlify

netlify Bot commented Nov 2, 2023 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik ready!

Name Link
🔨 Latest commit f81a028
🔍 Latest deploy log https://app.netlify.com/sites/authentik/deploys/65d460ef4a652d0008156d77
😎 Deploy Preview https://deploy-preview-7410--authentik.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tanberry tanberry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tiny edits, thanks for remembering to add docs!

Comment thread authentik/core/models.py Resolved
@BeryJu BeryJu self-assigned this Dec 28, 2023
@BeryJu BeryJu added the status/reviewing thanks for opening, we're taking a look label Dec 28, 2023
Comment on lines +77 to +79
raise ValidationError(
{"expires": f"Token expires exceeds maximum lifetime ({max_token_lifetime})."}
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we instead set the token expiration to something like min(attrs.get("expires"), token_expires_from_timedelta(max_token_lifetime_dt))?

@rissson rissson self-assigned this Feb 20, 2024
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
@netlify

netlify Bot commented Feb 26, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 12736d0
🔍 Latest deploy log https://app.netlify.com/sites/authentik-docs/deploys/6616ab94e761610008caa6fd
😎 Deploy Preview https://deploy-preview-7410--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
Comment thread authentik/core/models.py Resolved
@BeryJu
BeryJu merged commit a70363b into goauthentik:main Apr 11, 2024
kensternberg-authentik added a commit that referenced this pull request Apr 12, 2024
* main:
  website/docs: add more info and links about enforciing unique email addresses (#9154)
  core: bump goauthentik.io/api/v3 from 3.2024022.7 to 3.2024022.8 (#9215)
  web: bump API Client version (#9214)
  stages/authenticator_validate: add ability to limit webauthn device types (#9180)
  web: bump API Client version (#9213)
  core: add user settable token durations (#7410)
  core, web: update translations (#9205)
  web: bump typescript from 5.4.4 to 5.4.5 in /tests/wdio (#9206)
  web: bump chromedriver from 123.0.2 to 123.0.3 in /tests/wdio (#9207)
  core: bump sentry-sdk from 1.44.1 to 1.45.0 (#9208)
  web: bump typescript from 5.4.4 to 5.4.5 in /web (#9209)
  website: bump typescript from 5.4.4 to 5.4.5 in /website (#9210)
  core: bump python from 3.12.2-slim-bookworm to 3.12.3-slim-bookworm (#9211)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/reviewing thanks for opening, we're taking a look

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow end users to create app passwords with longer (or no) expiry

4 participants