Support least-privilege RBAC for apiops publish — avoid requiring Resource Group Reader in preflight

オープン
#303 コメント 4 件 リアクション 2 件 担当者 0 名 GitHub で見る

@cdayne がすでに取り組んでいます。

2026年11月5日 から。

  • #336 @cdayne による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
azure, typescript
領域
api, cli, cloud

調査の方向性

Start in src/clients/apim-client.ts at validatePreFlight() and trace the two sequential resource checks used by apiops publish. Confirm the chosen behavior preserves the APIM service existence check while allowing identities without resource-group read access; done means service-scoped publishing passes preflight without requiring Resource Group Reader.

索引モデルが issue の本文から書いたものです。

説明

stale type:feature
Problem or use case

apiops publish fails preflight validation unless the executing identity has
Reader (or broader) at the Resource Group scope, even though publishing
itself only ever touches the target APIM service/workspace.

validatePreFlight() (src/clients/apim-client.ts) performs two sequential
existence checks before publishing:

  1. GET {armEndpoint}/subscriptions/{sub}/resourceGroups/{rg} — requires
    Microsoft.Resources/subscriptions/resourceGroups/read, granted only by
    Reader (or higher) at resource group or subscription scope.
  2. GET {baseUrl} (the APIM service resource itself) — satisfied by
    Reader/Service Reader at APIM service scope.

Step 1 fails with a 403 for any identity scoped only to the APIM service,
before step 2 (the actually-relevant check) even runs:

AuthorizationFailed: The client does not have authorization to perform action
'Microsoft.Resources/subscriptions/resourceGroups/read' over scope
'/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'

Use case: organizations running a shared-APIM, multi-team model (one
resource group, several teams' service principals) currently must choose
between granting every team broad RG-scoped read access to every other
resource in the RG (other APIM instances, storage, App Insights, etc.), or
funneling all publishes through a single centrally-scoped identity — both
work against per-team least privilege. This also breaks parity with extract,
where workspace-scoped Reader + Service Reader (no RG scope) is already
sufficient.

Proposed solution

Scope the preflight check down to only what publish actually needs: read
access to the target APIM service. Step 2 above already GETs the APIM
service resource directly and will itself return 404 if the resource group
or instance doesn't exist, so the RG-level check in step 1 is purely
diagnostic (a slightly clearer "resource group not found" message) and isn't
load-bearing for correctness. Two options, in order of preference:

  1. Drop the RG-level check entirely and rely on the APIM-service GET
    (step 2) for existence validation. Slightly less specific error message
    on a missing RG vs. missing APIM instance, but removes the RG Reader
    requirement entirely.
  2. Make the RG check non-fatal: if it returns 403 specifically, log a
    warning and continue to step 2, only hard-failing on a genuine 404.
    Preserves the diagnostic for identities that do have RG-level access,
    without hard-blocking least-privilege ones.
Affected command

apiops publish

主要言語
TypeScript
スター
44
フォーク
14
PR マージ指標
30日以内にマージされた PR はありません

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Azure/apiops-cli のほかの issue

Azure/apiops-cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。