feat: Revamp udash login - #9924
Open
olblak wants to merge 1 commit into
Open
Conversation
Signed-off-by: Olblak <me@olblak.com>
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.
The goal of this pr is to have a credential that Updatecli can hold that does not expire, for CI and
laptops alike, with Zitadel as the identity backend.
Zitadel cannot issue one from an interactive login — access-token lifetime is a
project setting, default 12h. So the durable credential has to be one Udash
issues and validates itself. Once that is true, Updatecli only ever needs to
carry a bearer token, and its OAuth client stops earning its keep.
pkg/core/udash/was written against Auth0 and could not have worked against Zitadel:{issuer}/authorize,{issuer}/oauth/token/oauth/v2/authorizeand/oauth/v2/token?audience=<api>on the authorize requestaudienceparameter; audience comes from the scopeurn:zitadel:iam:org:project:id:{id}:audscope=offline_accesson the token requestgetAccessTokenread onlyaccess_tokenrefresh_tokenandexpires_inwere thrown awaystateparameterAfter this change Updatecli never contacts an identity provider.
What changed
Deleted
pkg/core/udash/main.goauthorizeUser,cleanup,getAvailablePort,var Audience— the whole PKCE flowpkg/core/udash/oauthInfo.gogetOauthInfo, theGET {front}/config.jsondiscoverypkg/core/udash/token.gogetAccessTokenonly; the config accessors stayedgo.modgithub.com/nirasan/go-oauth-pkce-code-verifiergithub.com/skratchdot/open-golang/openstayed — still used to open the tokenspage.
golang.org/x/termwas promoted from indirect to direct.pkg/core/udash/login.go— rewrittenThree ways to supply the token:
Before storing anything it calls
GET {api}/whoami, so a typo'd or revoked tokenfails at login, not silently three weeks later when a pipeline tries to
publish.
It also probes whether the service authenticates at all:
/whoamionly existswhen a mode is configured, so a 404 means the instance is open and no token is
asked for. Without that, the default auth-disabled deployment could not be
registered — this was caught by a test after the first implementation.
pkg/core/udash/whoami.go— newcallWhoami/requiresToken/whoami. An older Udash with no/whoamiendpoint is accepted rather than refused, since the rest of its API may work fine.
Bug fixes carried along
config_spec.go—writeConfigFileusedos.Create, landing the file at0644. World-readable, for a file holding a bearer token that now neverexpires. It is
0600.logout.go— when the last credential was removed the function returnedbefore
writeConfigFile, so logging out of your only configured service neverpersisted. The write moved above the early return.
CLI surface
--token--oauth-access-token--token--oauth-clientId,--oauth-issuer,--oauth-audience--api-url,--reportAPINo deprecation aliases as the feature is gated behind
--experimental.udash.Audience→udash.APIURLSelector. It was never an OAuth audience — it isthe selector for which stored credential to use, set by
--reportAPI. The sixidentical
--reportAPIregistrations across apply/diff/compose/pipeline movedinto
addReportAPIFlag, matching the existingaddXFlaghelpers incmd/flags.go.Test
To test this pull request, you can run the following commands:
Additional Information
Checklist
Tradeoff
Potential improvement