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

adds new script for administrator's reference regarding OAuth2 permission grants in Entra ID #6536

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

tmaestrini
Copy link

@tmaestrini tmaestrini commented Dec 26, 2024

Closes #6537

@milanholemans
Copy link
Contributor

Thank you @tmaestrini, could you also link the related issue to this PR?

@tmaestrini
Copy link
Author

Hey @milanholemans, thanks for getting back to me! It looks like you're always on the go! 😃 That's so cool! 👍
It is a part of a script that I've used while doing some work-related tasks. There is no related issue – the PR only adds a new script sample.

@milanholemans
Copy link
Contributor

Since we handle the principle of 1 issue = 1PR, could you create an issue for the completeness?

@tmaestrini tmaestrini changed the title new script sample: add new script for administrator's reference regarding OAuth2 permission grants in Entra ID adds new script for administrator's reference regarding OAuth2 permission grants in Entra ID Dec 26, 2024
@tmaestrini
Copy link
Author

Hey @milanholemans, sorry I missed that. See reference to issue in description field above.

@martinlingstuyl martinlingstuyl self-assigned this Jan 8, 2025
Copy link
Contributor

@martinlingstuyl martinlingstuyl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tmaestrini, my swiss, italian friend 🥂 I really love this sample, well done! I do have some comments to dot the t's and cross the i's. (or was that the other way around 😅) But anyway, let's look at some comments before we merge this!

@martinlingstuyl martinlingstuyl marked this pull request as draft January 8, 2025 20:36
@tmaestrini
Copy link
Author

@martinlingstuyl Muchas gracias, amigo! 🙌 Happy New Years 🥂 – and thank you very much for the review. Great balls of fire!
I've implemented all the fixes. Ready for review again!

@tmaestrini tmaestrini marked this pull request as ready for review January 8, 2025 22:25
Copy link
Contributor

@martinlingstuyl martinlingstuyl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK @tmaestrini, some last really small comments from my side. Let's fix those before we merge it. Very nice work!

"updateDateTime": "2024-12-25",
"shortDescription": "Find and remove all OAuth2 permission grants that have been assigned to a specific enterprise application (or service principal).",
"longDescription": [
"Find and remove all OAuth2 permissions assigned to a specific enterprise application by selecting one of the following removal options: **All permissions** / Permissions granted **by an administrator** / Permissions granted **to users**."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest rephrasing this slightly:

Suggested change
"Find and remove all OAuth2 permissions assigned to a specific enterprise application by selecting one of the following removal options: **All permissions** / Permissions granted **by an administrator** / Permissions granted **to users**."
"Find and remove all OAuth2 permissions assigned to a specific enterprise application by selecting one of the following removal options: **All permissions** / Permissions granted **by an administrator** / Permissions consented to **by users**."


Author: [Tobias Maestrini](https://github.com/tmaestrini)

From an administrator's perspective, managing OAuth2 permission grants that have been assigned to an enterprise application (used in a multi-tenant app or your own app registration) can be a challenging task.
Copy link
Contributor

@martinlingstuyl martinlingstuyl Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's swap them around (that's just a feeling, feel free to ignore) and slightly rephrase.

Suggested change
From an administrator's perspective, managing OAuth2 permission grants that have been assigned to an enterprise application (used in a multi-tenant app or your own app registration) can be a challenging task.
From an administrator's perspective, managing OAuth2 permission grants that have been assigned to an enterprise application (based on an app registration or a multi-tenant app) can be a challenging task.

Removes OAuth2 permission grants in a specific enterprise application (or service principal) in Entra ID.

.DESCRIPTION
Find and remove all OAuth2 permissions assigned to a specific enterprise application by selecting one of the following removal options: **All permissions** / Permissions granted **by an administrator** / Permissions granted **to users**.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Find and remove all OAuth2 permissions assigned to a specific enterprise application by selecting one of the following removal options: **All permissions** / Permissions granted **by an administrator** / Permissions granted **to users**.
Find and remove all OAuth2 permissions assigned to a specific enterprise application by selecting one of the following removal options: **All permissions** / Permissions granted **by an administrator** / Permissions consented to **by users**.

- User must have appropriate permissions in Entra ID to manage OAuth2 permission grants (e.g. Global Admin)

.LINK
https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/manage-application-permissions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
https://learn.microsoft.com/en-us/azure/active-directory/manage-apps/manage-application-permissions
https://learn.microsoft.com/azure/active-directory/manage-apps/manage-application-permissions


.NOTES
Prerequisites:
- Microsoft 365 CLI (m365) must be installed and configured
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Microsoft 365 CLI (m365) must be installed and configured
- CLI for Microsoft 365 (m365) must be installed and configured

.NOTES
Prerequisites:
- Microsoft 365 CLI (m365) must be installed and configured
- User must have appropriate permissions in Entra ID to manage OAuth2 permission grants (e.g. Global Admin)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the role "Cloud Application Administrator" can also be used. Let's mention that one as well to show you dont always need god mode.

And let's add one extra prerequisite:

- The Entra app registration used to sign into the CLI for Microsoft 365 must have an appropriate permission scope to manage permissions of other apps (e.g. Directory.ReadWrite.All).

You could also try to find out the least permissive scope to use here. I don't know it by heart, but Directory.ReadWrite.All is a bit massive for this.

function Remove-PermissionsGrants {
param(
[Parameter(Mandatory = $true)]
[string]$enterpriseAppName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's capitalize this one, just like GrantType.

Suggested change
[string]$enterpriseAppName,
[string]$EnterpriseAppName,

You could also rename it to AppDisplayName. It's not really important here that it is called an 'enterprise' application.

@martinlingstuyl martinlingstuyl marked this pull request as draft January 9, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants