Skip to content

TUI keeps the AS-1 sign-in signal when the issuer uses a private CA #2655

Open

Description

@ChrisJBurns

Phase 3. Not needed for phases 1 and 2. Without the signal, unary calls still refresh and retry once on bearer_rejected, so each new session costs one extra round trip that the user does not see. A stream that reopens a session after the refresh token's hard expiry fails once instead of retrying. Discovered login is not a workaround on the local Kind profile, because its issuer transport refuses loopback and private addresses.

Depends on: #2491.

Problem

The TUI decides whether to refresh its access token before each session open, and whether to send the Mecatl API audience as the RFC 8707 resource, from the com.stacklok.mecatl.identity_broker_sign_in member of mecak8s's protected-resource metadata (#2491). It saves that signal only through discovered login: discoveredEnrollmentFrom sets IdentityBrokerSignIn (cmd/mecatui/login.go).

Discovered login refuses --tls-ca and --private-issuer. Those flags need an explicit --issuer, --client-id, and --audience (cmd/mecatui/login.go, "require explicit --issuer"), and the explicit path never reads the metadata. So when AS-1's issuer uses a private CA, the TUI never learns the signal. The local mecak8s-idbroker profile logs in exactly this way (deploy/mecak8s-idbroker/Taskfile.yml, login), and so would any deployment whose AS-1 has a private CA.

Without the signal, the TUI sends no resource and does not refresh before an open. Once the broker converts sign-ins at the real AS-1 (#2607), each open takes the token once. The next session open then presents a spent token and gets a bearer_rejected 401 before the TUI retries with a fresh one. This happens on every new session, including in the demo (#2542).

Design

Requirements

One of these, chosen in the PR:

  • Discovery with a private issuer CA: discovered login accepts --tls-ca for the issuer when the discovered issuer has the same origin as the resource, or when the operator confirms it. The confirmation prompt shows the CA. --private-issuer keeps its current meaning.
  • Explicit login reads the signal: explicit --issuer login also fetches mecak8s's protected-resource metadata, using the server's CA (--server-tls-ca). If the metadata names the same issuer, the TUI saves identity_broker_sign_in. If the metadata names a different issuer, login fails rather than mixing identities.

Either way, the TUI never trusts a CA for an issuer the operator did not name or confirm. Saved connections from before this change keep working and are not rewritten silently.

Update the local profile's login task, and the operating guide if a flag changes.

How it fits

Sign-in (slice 3): with this, the TUI's sign-in behaves the same whether or not AS-1 uses a private CA.

Done when

  • With the mecak8s-idbroker profile, mecatui login saves identity_broker_sign_in.
  • Two session creates in a row send access tokens with different jti values and get no bearer_rejected retry. A test with the offline harness proves this through the real login path.
  • A discovered issuer with a different origin and an unconfirmed CA is refused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions