Repository navigation
Default APIM migration to Entra and gate runtime key opt-in - #76
Open
Paul Yuknewicz (paulyuk) wants to merge 3 commits into
Open
Paul Yuknewicz (paulyuk) wants to merge 3 commits into
Paul Yuknewicz (paulyuk) wants to merge 3 commits into
Conversation
Never recreate APIM's built-in master subscription as a gateway key. Direct its callers to the existing manual Entra RBAC prerequisite with explicit object IDs and least-privilege model/tool scopes. Reject master targets in older plans and keep caller cutover separate from configuration completion. Deliberately update the golden plan for the changed subscription rationale and caller-RBAC guidance. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
List Entra RBAC first with explicit no-key behavior. Describe per-consumer keys only as an opt-in for non-Entra clients. Lead caller prerequisites and documentation with identities and least-privilege model/tool scopes, while retaining normal phase completion and master-key guards. Deliberately update the golden plan for the normative access choices and prerequisite wording. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
3 tasks
Keep Entra as the default. Align key opt-in prerequisites and client guidance with the gateway-wide Phase 2 runtime access contract, without claiming unsupported disableLocalAuth detection. Update the golden plan to match the clarified access choices. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
c37a6ed12b3842cb84b86ff9cad0c98afc0336c5↑ Rehearsal, acknowledged execution, prerequisite removal, and pinned-wheel surface compatibility are covered.
↓ No live gateway or caller cutover exercised; Owner acknowledgment is manual and can become stale.
↑ New regressions reproduced key-phase writes without the required Owner confirmation.
↓ The reported live target was not exercised; automatic setting detection is unavailable in the current API definition and pinned CLI.
Default migration path
Use Microsoft Entra ID for runtime callers. The default migration creates no API keys: accept
entra-rbac, grant each caller runtime access to its required models, aliases, or MCP servers, and switch the caller to Entra tokens.Key-based access is a gateway-wide setting, not a kind of API key. Under the Phase 2 runtime access contract,
properties.disableLocalAuthdefaults totruefor new gateways, while pre-Phase 2 gateways initialize tofalse. Only a gateway Owner can change it. Enabling requires static-key risk acknowledgment and is subject to Azure Policy. These are contract semantics, not a claim that rollout is complete or that the current API/CLI exposes the setting. Migration does not toggle the target's setting. Entra is the expected path for both new and existing gateways.The planner already proposed
entra-rbac, but listed keys first and gave the choices no consequences. It now lists Entra first and states the no-key default in the choice, rationale, caller prerequisite, and operator documentation. Tests cover both the initial proposal and acceptance for ordinary, master-only, and mixed subscription inventories.The operator supplies each caller's Entra object ID, principal type, and least-privilege model/tool scopes through
prereq:caller-rbac. Shared APIM credentials cannot identify their consumers. Apply does not discover those identities or create their role assignments. Keep callers on APIM until their identity mapping, role grants, token cutover, and runtime checks are complete.Run every configuration phase in order, including
keys, which creates no keys on the default path. No skip or journal override is needed. Configuration completion does not acknowledge the caller prerequisite or prove runtime access.Operator commands
Inspect
item:access/subscriptions, accept theentra-rbacproposal by settingstatustoadaptedanddecisiontoentra-rbac, then regenerate the plan. Replace the placeholders below before running the role commands.Use the Entra object ID, not application/client ID. Principal type is
User,Group, orServicePrincipal, includingServicePrincipalfor managed identities. An alias scope is<gateway-resource-id>/workspaces/default/aliases/<alias-name>; an MCP-server scope is<gateway-resource-id>/workspaces/default/toolServers/<server-name>.Explicit opt-in for non-Entra clients
Choose
gateway-key-per-consumeronly for clients that cannot use Entra. It creates fresh gateway-wide keys for ordinary APIM subscriptions, never the built-inmastersubscription. Distribute the replacement credentials and change those clients separately; no APIM key value is imported. Migrated clients useAuthorization: Bearer <key>orapi-key: <key>, neverx-api-key. Each named key follows the single-secret contract, with no secondary key. Backend provider credentials are a separate contract.Stop before executing
keysuntil a gateway Owner confirms that key-based access is enabled, with the required risk acknowledgment and Azure Policy compliance. The plan addsprereq:key-based-access; execution refuses the entire keys phase before any step without its acknowledgment, including telemetry writes in that phase. Earlier configuration phases can provision the target first. Rehearsal remains available.When access is disabled under Phase 2, key metadata GET and DELETE remain available, but authorized mutations and
listSecretsfail with409 LocalAuthDisabled; runtime key requests fail with401. Metadata read-back does not prove that keys work. If the state cannot be established, access is disabled, or policy forbids it, stop key opt-in and re-plan for Entra. Acknowledgment records Owner confirmation, not a live check, and can become stale. Preflight continues to reportkeyAccessUnverifiedafter acknowledgment.The original defect included master in the key option and attempted to create it when absent. This PR excludes it from target generation and rejects older plans that still contain it during preflight and in the key builder. Re-plan older artifacts. Entra is the default, so migration never recreates that shared all-access credential. A service-wide scope or an "All access" display name does not make an ordinary subscription master.
Follow-up: automatic key-access detection
The current AIGateway API definition and pinned CLI do not expose
disableLocalAuth. This change deliberately adds no speculative property read, API version, CLI flag, or automatic toggle. Add live state detection when a supported API/CLI exposes the setting, and replace the manual unknown-state boundary with a pre-write check. Until then, the gate requires Owner confirmation through a supported product control; inability to establish the state means using Entra instead.Validation and related work
python -m migrate_apim compile --strict: zero errors and warnings.git diff --checkpassed. No CLI core or extension implementation changes, so azdev extension gates do not apply.valid.