CLI Browser OIDC PKCE Login v1¶
Purpose¶
gpuaas auth login should use the same brokered identity path as the web product.
Password grant is useful for local/dev and breakglass testing, but it is not the
primary model for a cloud CLI because social and enterprise providers such as Hugging
Face, GitHub, and SSO do not fit a username/password prompt.
Command Model¶
Primary human login:
gpuaas auth login
gpuaas auth login --provider huggingface
gpuaas auth login --provider github
gpuaas auth login --tenant-hint acme --identity-hint user@acme.example
gpuaas auth login --no-browser
Development-only password flows:
gpuaas auth dev-login --username dev-user --password dev123
gpuaas auth keycloak-login --username dev-user --password dev123
Automation flow:
Browser Login Flow¶
- CLI generates a PKCE verifier and S256 challenge.
- CLI starts a localhost callback listener on
127.0.0.1:<ephemeral>/callback. - CLI calls
GET /api/v1/auth/oidc/authorizewith: redirect_uri,code_challenge,code_challenge_method=S256,- optional
provider_hint, - optional
tenant_hint, - optional
identity_hint. - API returns a server-authoritative authorization URL and opaque state.
- CLI opens the browser unless
--no-browseris set. - Browser completes the IdP flow and redirects to the localhost callback.
- CLI validates callback state before token exchange.
- CLI calls
POST /api/v1/auth/oidc/exchangewith code, verifier, redirect URI, and state in the JSON body. - CLI stores access and refresh tokens in the existing CLI config file.
The CLI never receives or passes access tokens in URL query parameters.
Provider Hints¶
Provider hints are advisory shortcuts. The server remains authoritative.
Supported first-pass values:
huggingface,github,google.
The API maps the validated hint to the brokered IdP hint understood by Keycloak. The CLI does not construct direct provider URLs and does not bypass the GPUaaS API.
Headless Behavior¶
--no-browser prints the authorization URL and still waits for the localhost callback.
This supports SSH sessions where the user can open the URL from another local browser
that can reach the callback endpoint through forwarding.
A true device-code flow is a later addition because the current API contract exposes authorization-code exchange, not OAuth device authorization. Until that endpoint exists, service-account auth remains the correct non-interactive automation path.
Security Rules¶
- Use PKCE S256 for every human browser login.
- Keep authorization codes, access tokens, refresh tokens, and client secrets out of logs.
- Do not pass access or refresh tokens in URL query parameters.
- Validate callback state before exchange.
- Store tokens using the existing restricted-permission CLI config initially.
- Move to OS keychain storage later as a separate hardening task.
- Keep service-account auth for CI and automation.
- Keep password grant commands clearly labeled as dev/breakglass paths.
UX Implications¶
The normal help path should point users to:
not to password grant. Brokered identities should work without asking users to know whether the underlying provider is Keycloak, Hugging Face, GitHub, or enterprise SSO.
Implementation Notes¶
The first implementation keeps token persistence compatible with the existing SDK config file:
That preserves current CLI behavior while changing the default login path. Future hardening can move refresh-token storage to an OS keychain without changing the CLI command contract.