Fix @armProviderNamespace default auth scope#4322
Conversation
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/fdffd82d-eeb0-4bdc-9b8c-91a7f3bdfad8 Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
@armProviderNamespace default auth scope
markcowl
left a comment
There was a problem hiding this comment.
Please pull the latest from main, make the changes suggested, verify all tests pass and all files are correctly formatted, and that only the changes related to this PR are in the pr diff.
…ernamespace-scope Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Azure/typespec-azure/sessions/ac63ed4e-5355-4de4-9e94-d3f565688bf7 Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Done in 8e8f4a0. Merged latest |
|
/azp run typespec-azure - PR Tools |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
All changed packages have been documented.
Show changes
|
commit: |
|
You can try these changes here
|
1 similar comment
|
You can try these changes here
|
@armProviderNamespaceinjects a bareuser_impersonationOAuth2 scope, which SDK emitters cannot resolve to an ARM audience at runtime (tokens end up issued for Microsoft Graph). Per the issue discussion (option 2 / 2a), TypeSpec should carry the real scope andtypespec-autorestshould project it back to the legacy value so existing ARM Swagger inazure-rest-api-specsis unchanged.Changes
typespec-azure-resource-manager/src/namespace.ts:@armProviderNamespacenow injectshttps://management.azure.com/.defaultwith the description"Default scope for management APIs"as the sole default scope. Consumers like TCGC / downstream SDK emitters now see the canonical ARM scope.typespec-autorest/src/openapi.ts: AddedrewriteArmScopeForOpenAPI2, applied in bothgetOpenAPI2Scheme(securityDefinitions) andgetOpenAPISecurity(per-op security refs). When the service namespaceisArmProviderNamespaceand the scope value is exactlyhttps://management.azure.com/.default, it is rewritten back touser_impersonation. When this rewrite happens, the description is also projected back to the legacy"impersonate your user account"so existing ARM swagger baselines stay byte-identical. Any other scope / non-ARM namespace is passed through unchanged, so existingsecurity.test.tscoverage (e.g. customread/writescopes) still holds, and all ARM sample openapi.json baselines remain byte-identical.typespec-azure-resource-manager/test/authentication.test.ts: assertsgetAuthenticationon an@armProviderNamespacenamespace yields exactly one OAuth2 implicit flow with scopehttps://management.azure.com/.defaultand description"Default scope for management APIs".typespec-autorest/test/arm/authentication.test.ts: asserts the emitted OpenAPI v2 still containsazure_auth/user_impersonation(with the original"impersonate your user account"description) in bothsecurityDefinitions.azure_auth.scopesandsecurity.fixchangelog entry covering both packages.Shape of the rewrite
Notes / follow-ups