feat(auth): support custom token name and lifetime in webauth login#304
Open
tomaskir wants to merge 1 commit into
Open
feat(auth): support custom token name and lifetime in webauth login#304tomaskir wants to merge 1 commit into
tomaskir wants to merge 1 commit into
Conversation
phase auth (webauth mode) always minted a non-expiring PAT named
username@hostname, with no way to override either. Add two optional flags
and send the values to the Console in the webauth request payload:
- --token-name sets the PAT name (default username@hostname). This fixes
unhelpful names under Docker, where the default becomes root@<container-id>.
- --token-lifetime sets the PAT lifetime, e.g. 7d, 12h, 30m, 60s, 2w
(default: never expires).
The webauth payload moves from the hyphen-joined port-pubKeyHex-patName
string to base64(JSON) { port, publicKey, name, lifetime? }, where lifetime
is in seconds. This is parse-safe for names containing hyphens or other
characters and matches the Console webauth page contract.
Add util.ParseTokenLifetime to convert a lifetime string into seconds.
Console side: phasehq/console#928, phasehq/console#937 (PR phasehq/console#938).
Closes phasehq#302
Closes phasehq#303
13f65ab to
b2ed17b
Compare
Author
|
Coordinated Console side: phasehq/console#938 (parses the base64(JSON) webauth payload and mints the PAT with the requested name and lifetime). |
This was referenced Jun 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds two optional flags to
phase auth(webauth mode) so the minted personal access token's name and lifetime can be set at login, instead of the token always being a non-expiringusername@hostnamePAT.--token-namesets the PAT name (defaultusername@hostname). Fixes unhelpful names under Docker, where the default resolves toroot@<container-id>(feat: allow setting the token name during phase auth #303).--token-lifetimesets the PAT lifetime:7d,12h,30m,60s,2w(default: never expires) (feat: allow requesting a token with a specific lifetime during phase auth #302).Parse-safe payload change: the webauth request payload moves from the hyphen-joined
port-pubKeyHex-patNamestring to base64(JSON){ port, publicKey, name, lifetime? }(lifetime in seconds; omitted = never expires). This is needed because a user-supplied name can contain hyphens and other characters that the old naive split on-truncated, and it matches the Console webauth page contract.New helper
util.ParseTokenLifetimeconverts a lifetime string to seconds (units:s,m,h,d,w).Requires the Console side to honor the values: phasehq/console#928 and phasehq/console#937, implemented in phasehq/console#938.
Closes #302
Closes #303
Verification
go vet ./...,CGO_ENABLED=0 go build(CI smoke test), andgo test ./...pass on Go 1.24.util.ParseTokenLifetimeis unit-tested (units, trimming/case-insensitivity, invalid inputs).phase auth --token-lifetime 7d --token-name "ci-prod-api"->{"port":...,"name":"ci-prod-api","lifetime":604800}(604800 = 7d)phase auth(no flags) ->{"port":...,"name":"root@<container-id>"}, lifetime omittedphase auth --token-lifetime 7x-> clean validation errorType