Skip to content

Azure: interactionRequired names the tenant to sign in to - #115

Open
odgrim wants to merge 1 commit into
track-a/azure-detect-gapsfrom
track-a/azure-interaction-tenant
Open

odgrim wants to merge 1 commit into
track-a/azure-detect-gapsfrom
track-a/azure-interaction-tenant

Conversation

@odgrim

@odgrim odgrim commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Change

When the person must sign in to an Azure tenant, Azure's interactionRequired now gives the tenant's id and, where known, its name. Runbooks prefills the sign-in form's tenant from id and shows name, as Runbooks main named the tenant and prefilled "Tenant to sign in to".

  • Detection and sign-in, default tenant wants MFA. When no tenant gives a token, detect and a fresh signIn used to fail accessDenied with az's AADSTS text. They now fail interactionRequired for az's default tenant, named as the login names it. No session exists afterwards, so Runbooks prefills the sign-in's tenant from id; a signInTo answers notSignedIn.
  • Detection, tenant pinned by domain. A pinned domain whose tenant wants MFA or a new sign-in fails interactionRequired with the domain as id, which signInTo takes.
  • Listing subscriptions. targets for a tenant the login holds no account in used to list nothing. It now answers interactionRequired for that tenant, so the person learns it needs a sign-in when they pick it, not after picking None.
  • Choosing a tenant. select and a resumed choice already answered interactionRequired for a tenant that wants MFA, a new sign-in, or holds no account. They now name it.

Decisions

  • PluginError::interaction_required takes name: Option<String>. Every caller passes one. runbooks-plugin-transport is not published.
  • Accounts.in_use is an Account (id and tenant), not a bare SubscriptionId. az account get-access-token without --tenant uses the default account's tenant. With the tenant in the same value, the tenant can't drift from its account. Callers that need only the id take .id.
  • One helper, sign_in_fixes, decides which refusals a sign-in fixes: MFA and a new sign-in. A tenant that denies the login keeps az's error.
  • targets reuses Session::default_account. That is the check select already makes for a tenant with no account.
  • A tenant pinned by domain is named by nothing. name is left out; the domain in id is already readable.

Gaps

  • Untested:
    • a failure a sign-in doesn't fix, such as network, keeping its kind at the default tenant and at a domain pin;
    • another tenant's token winning when az has a default account: every test world has none;
    • signInTo after a failed signIn answering notSignedIn.
  • With a tenant pinned by id and both tenants wanting MFA, the answer names az's default tenant, not the pinned one.
  • targets calls Session::default_account only for its error.
  • az's error text is quoted in the message unredacted, as it was in the accessDenied before.
  • DisplayName drops control characters only, so U+202E and U+2028 reach name and "Sign in to to use it". interaction_required takes name as a String, not a DisplayName.
  • When az's saved accounts can't be read, or none is az's default, detection still fails with az's error: there is no tenant to name.
  • targets for a tenant id the login can't see at all now answers interactionRequired, not an empty list. Runbooks asks only for tenants targets listed.
  • Two az_cli proxy tests (an_id_token_request_never_goes_through_the_environments_proxy, a_requested_federated_token_comes_through_the_proxy_onto_stdin) failed once at 10 s in a loaded mutant run. They pass alone in 7 to 10 s, so they sit close to their bound. This change doesn't touch them.

Evidence

  • a_detected_login_needs_a_sign_in_to_the_tenant_that_wants_mfa (new):
    • with Contoso (az's default) and Fabrikam both wanting MFA, detect fails with {"kind": "interactionRequired", "level": "tenant", "id": CONTOSO, "name": "Contoso"};
    • with a pin of fabrikam.onmicrosoft.com and Fabrikam wanting MFA, the same data with the domain as id and no name;
    • both pass the schema's interactionRequiredData.
  • a_tenant_missing_from_the_profile_needs_a_sign_in_to_it now lists Fabrikam's subscriptions first and gets interactionRequired named "Fabrikam", then the same from select.
  • a_tenant_that_refuses_a_token_says_whether_a_sign_in_fixes_it expects the name.
  • interaction_required_names_the_level_and_target (transport) covers the data with and without name.
  • Hand mutants, each failing one test (188 passed, 1 failed):
    • no default tenant named;
    • a domain pin keeping az's error;
    • targets listing a tenant with no account;
    • a tenant with no account left unnamed;
    • commit leaving its tenant unnamed.
  • The fake az's tenant_of now finds a tenant-level account by its tenant id, as az lists one. Without it, a_failed_sign_in_to_puts_back_a_default_its_login_moved lost the default a failed login moved.
  • mise run check at 4bdfca5: 508 tests run: 508 passed, 0 skipped, lint clean, semver no publishable crates.
  • CI at 01831a1: mutation test 20 mutants: 12 caught, 8 unviable. Audit dependencies is red, as on main, until the pin-project-lite 0.2.19 lock update.
  • Rebased for the stack, 531800c to 33ee5d0: the PR's diff has the same git patch-id --stable (29daf91b875f) and the same changed lines, tree unchanged.

PluginError::interaction_required takes the target's name. Azure gives
the tenant's id and name when:

- detection finds no tenant that gives a token, because az's default
  tenant wants MFA: the default tenant, named as the login names it;
- a tenant pinned by domain wants MFA or a new sign-in: the domain;
- targets lists a tenant the login holds no account in;
- select or a resume chooses a tenant that wants MFA, a new sign-in, or
  holds no account.

Accounts.in_use carries its tenant, so the default tenant is known.
@odgrim
odgrim force-pushed the track-a/azure-interaction-tenant branch from 531800c to 33ee5d0 Compare December 6, 2026 16:03
@odgrim
odgrim added this pull request to stack #118 December 6, 2026 16:04
@odgrim
odgrim marked this pull request as ready for review December 6, 2026 16:14

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant