Skip to content

Little/max api token duration - #1946

Merged
Eugeny merged 7 commits into
warp-tech:mainfrom
SteezyCougar:little/max-api-token-duration
May 26, 2026
Merged

Little/max api token duration#1946
Eugeny merged 7 commits into
warp-tech:mainfrom
SteezyCougar:little/max-api-token-duration

Conversation

@SteezyCougar

Copy link
Copy Markdown
Contributor

We have two use-case that this PR solves

  1. We want to ensure no token can last longer than we set our max to be
  2. We use a local development tool that we want to make it easy for them to create a token so that the tool can grant them access easier to resources without them having to be involved (Hence why we want to be able to restrict the valid timeframe of said tokens)

Enforces a maximum lifetime on API tokens to prevent indefinite
access without re-authentication. Default: 7 days (604800s).
Set to null to disable enforcement.

- New migration (m00046) adds column to parameters table
- Server rejects token creation if expiry exceeds the configured max
- Frontend pre-populates expiry with the max (or 7 days) and shows
  the limit in the creation modal
- Admin API exposes the parameter for configuration
The token page now reads query params from the hash route:
- ?create=true  — auto-opens the creation modal
- ?label=X      — pre-fills the label field
- ?expiry=7d    — pre-sets expiry (supports Nd, Nh, Nm format)

This enables CLI tools to open a pre-filled URL so users only
need to click Create and copy the resulting secret.
These are gitignored and regenerated at build time.
- Merge time::{Duration, OffsetDateTime} import (rustfmt compliance)
- Report max duration in seconds in error message (avoid truncation)
- Add try/catch + error display for token creation failures
- Change migration default to NULL (no limit) to avoid breaking
  existing installs on upgrade
Comment thread warpgate-web/src/gateway/ApiTokenManager.svelte Outdated
@Eugeny
Eugeny merged commit 50d4938 into warp-tech:main May 26, 2026
18 checks passed
tenfourty pushed a commit to tenfourty/warpgate that referenced this pull request Jul 4, 2026
We have two use-case that this PR solves

1. We want to ensure no token can last longer than we set our max to be
2. We use a local development tool that we want to make it easy for them
to create a token so that the tool can grant them access easier to
resources without them having to be involved (Hence why we want to be
able to restrict the valid timeframe of said tokens)

---------

Co-authored-by: Eugene <inbox@null.page>
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.

2 participants