Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RBAC] Updates to az ad app permission list/add/delete #13325

Closed
wants to merge 3 commits into from

Conversation

psignoret
Copy link
Contributor

@psignoret psignoret commented May 4, 2020

Description

Various updates to az ad app permission commands for managing required API permissions on app registrations:

  • az ad app permission add
    • Remove message suggesting that running az ad app permission grant --id {id} --api {api} will grant the permissions added. (This was inaccurate and there's no command currently that can be used to grant both application and delegated permissions.)
    • Add support for identifying target API by identifier URI and service principal object ID.
  • az ad app permission delete
    • Add support for removing an individual required permission.
    • Add support for identifying target API by identifier URI and service principal object ID.
  • az ad app permission list
    • Set delegated permission grant expiry time to a date far in the future. This is slightly more accurate than the current approach, since the real "expiryTime" values are ignored by the service.
    • Add option to skip retrieving delegated permission grants (avoids several unnecessary queries and improves performance).
  • Other:
    • Refactor show_service_principal to avoid an unnecessary query in several scenarios.
    • Expanded tests to cover more scenarios and to tear down more cleanly.

Testing Guide

See examples added in _help.py.

History Notes

[RBAC] az ad app permission list: Now includes a date far in the future as "expiryTime" when listing required permissions and there exists at least one tenant-wide delegated permission grant for the API in question. (The real "expiryTime" values are not enforced by the server, so it is more accurate to state the the permission grant expires far in the future.) Use az ad app permission list-grants to list all delegated permission grants.

[RBAC] az ad app permission add: Add support for identifying the API by identifier URI.

[RBAC] az ad app permission delete: Add support for identifying the API by identifier URI, and add support for removing individual required permissions.


This checklist is used to make sure that common guidelines for a pull request are followed.

@psignoret psignoret requested a review from jiasli as a code owner May 4, 2020 23:02
@yonzhan yonzhan requested review from qianwens and arrownj May 4, 2020 23:06
@yonzhan yonzhan added this to the S169 - For Build milestone May 4, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented May 4, 2020

add to S169

@psignoret psignoret force-pushed the phsignor-required-permissions branch 4 times, most recently from 102f2f2 to 91385c4 Compare May 4, 2020 23:46
@jiasli
Copy link
Member

jiasli commented May 5, 2020

Hi @psignoret, thanks a lot for the contribution. We are on public holiday. I will review this PR tomorrow. By the way, az ad app permission grant does work with delegated permissions. Could you take a look at #12137 (comment)?

@psignoret
Copy link
Contributor Author

Yes, az ad app permission grant does work for delegated permissions, but it only works for delegated permissions, not for application permissions, where az ad app permission add|delete|list apply for both delegated permissions ("Scope") and application permissions ("Role"). The message telling the user to call az ad app permission grant --id {id} --api {api} had two issues:

  1. The message suggests that with az ad app permission grant any permission can be granted (when in fact it's only for delegated permissions).
  2. If the user was to copy-paste the command proposed by that message (without any scopes specified), the scope value "user_impersonation" would be granted, which is not necessarily valid, nor is it necessarily the permission which the user had added to the required permissions.

I'm working on a separate PR to add support for application permissions (app role assignments). Once that's implemented, we can update admin-consent to use this.

@psignoret
Copy link
Contributor Author

@jiasli Have you had a change to review this PR?

@jiasli
Copy link
Member

jiasli commented May 14, 2020

Thanks @psignoret, I still haven't got a chance to review it as AD Graph API is not our priority. I don't think we will use the term admin-consent anymore. In fact, the whole command group needs an overhaul to better distinguish between delegated permissions and application permissions.

We actually plan to do this in MS Graph migration, as the current work may be discarded during the process.

@yonzhan yonzhan modified the milestones: S169 - For Build, S170 May 16, 2020
@jiasli jiasli marked this pull request as draft May 18, 2020 09:41
@psignoret psignoret marked this pull request as ready for review May 18, 2020 15:35
@psignoret psignoret force-pushed the phsignor-required-permissions branch from 5f54f03 to b3e989e Compare May 18, 2020 16:05
* If at least one tenant-wide delegated permission exists, expiryTime is set to a date far in the future.
* New parameter --skip-grant-expiry-time to avoid retrieving the grants, which adds several unnecessary queries.
@psignoret psignoret force-pushed the phsignor-required-permissions branch from b3e989e to 91ca818 Compare May 18, 2020 21:46
@psignoret psignoret requested a review from jiasli May 19, 2020 08:58
@yonzhan yonzhan modified the milestones: S170, S171 May 31, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented May 31, 2020

add to S171

@jiasli jiasli marked this pull request as draft June 9, 2020 13:04
@yonzhan yonzhan removed this from the S171 milestone Jun 20, 2020
@yonzhan yonzhan added this to the S172 milestone Jun 20, 2020
@yonzhan yonzhan modified the milestones: S172, S173, Backlog Jul 12, 2020
@psignoret psignoret closed this Sep 25, 2022
@psignoret psignoret deleted the phsignor-required-permissions branch September 25, 2022 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants