Skip to content

Test that one upstream identity never maps to two authorization-server users #6980

Done

Description

@jhrozek

Part of #6886.

Problem: clients compare the user's sub_id (the issuer and subject at the company IdP) to decide who owns a session, and an agent check compares it with a grant's user. Both assume that no two authorization-server users ever carry the same sub_id. The code appears to guarantee it: a user is found by (provider, upstream subject), and the link is created with an atomic set-if-absent. Nothing tests it.

Change: tests, and one startup check.

  • Test concurrent first logins for one upstream identity, on memory and Redis storage: exactly one user results, and the losing login fails cleanly and succeeds on retry, with no orphaned user.
  • Test repeat logins: the same identity always resolves to the same user.
  • Reject, at startup, two upstream providers configured with the same issuer. The link key includes the provider ID, so two entries for one issuer would give one person two users with the same sub_id.
  • Document the invariant next to sub_id.

Acceptance:

  • the concurrent test passes repeatedly under the race detector, on both backends;
  • a configuration with two providers for one issuer fails at startup with a clear message;
  • a test fails if a second user can be created for an existing (provider, subject).

Activity

  1. added
    needs-triage
    on Oct 28, 2026
  2. jhrozek commented on Nov 24, 2026

    @jhrozek
    ContributorAuthor

    Ownership note: the tests here run against the storage in "User-keyed
    upstream storage behind the embedder option" (#7263) on the storage track; the
    startup refusal of two upstreams with the same issuer is the
    authorization server track's. Neither shipped with the setting-and-gate
    PR. "Bind provider-identity rows to the issuer and subject claim that
    created them" (#7256) is detached from this issue: it's hardening for
    after resolution is enabled, and must not hold up "Delegated access: turn on subject resolution at ID-JAG redemption" (#7247).

  3. removed
    needs-triage
    on Nov 24, 2026
  4. jhrozek commented on Nov 24, 2026

    @jhrozek
    ContributorAuthor

    The PR for this ("Keep one user per upstream identity", #7277) changes two of the acceptance items, so here's what it does instead:

    • No startup check for two upstreams with the same issuer. Only the first upstream can create users now, so a second provider for the same issuer can't produce a second user. A later upstream only resolves through a link that already exists. The startup check would also refuse setups that are safe under that rule.
    • The login that loses the race doesn't fail and retry. It reads the link the winner wrote, rolls back its own user, and returns the winner's user, so both logins succeed with the same user.

    The other items are covered as written: concurrent first logins on memory and Redis under the race detector, repeat logins, a contract test that refuses a second link for the same (provider, subject), and the rule documented next to sub_id.

    What's still open is the case where an upstream keeps its name but points at another issuer. That's "Bind provider-identity rows to the issuer and subject claim that created them" (#7256).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions