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

[Feature Request] Support custom client ID #22775

Open
jiasli opened this issue Jun 8, 2022 · 11 comments
Open

[Feature Request] Support custom client ID #22775

jiasli opened this issue Jun 8, 2022 · 11 comments
Assignees
Milestone

Comments

@jiasli
Copy link
Member

jiasli commented Jun 8, 2022

Related command
az login

Is your feature request related to a problem? Please describe.
Currently Azure CLI uses a fixed client ID to authenticate into AAD

AZURE_CLI_CLIENT_ID = '04b07795-8ddb-461a-bbee-02f9e1bf7b46'

This client ID 04b07795-8ddb-461a-bbee-02f9e1bf7b46 is a First Party Application, registered in First Party Portal.

This application is only pre-authorized for a limited set of Microsoft Graph permissions. Using Azure CLI command az rest to call trustFrameworkKeySet API which requires TrustFrameworkKeySet.Read.All, TrustFrameworkKeySet.ReadWrite.All will fail (#22755).

Describe the solution you'd like
Support custom client ID, so that users can create their own app in their tenant, consent to that app and let Azure CLI use that app’s client ID:

az login --client-id

Describe alternatives you've considered
Apply for those permissions in First Party Portal to support these APIs.

@ghost ghost added Auto-Assign Auto assign by bot Account az login/account labels Jun 8, 2022
@ghost ghost assigned jiasli Jun 8, 2022
@ghost ghost added this to the Backlog milestone Jun 8, 2022
@ghost ghost added Graph az ad CXP Attention This issue is handled by CXP team. AAD labels Jun 8, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented Jun 8, 2022

Support custom client ID

@navba-MSFT navba-MSFT removed the CXP Attention This issue is handled by CXP team. label Jun 8, 2022
@navba-MSFT
Copy link
Contributor

Removing CXP Attention label from this issue since this was created internally by SDK team

@jiasli
Copy link
Member Author

jiasli commented Sep 16, 2022

We received a similar issue today that the user wants to use Azure CLI's client ID to call b2cIdentityUserFlows API which requires delegated permission IdentityUserFlow.Read.All, IdentityUserFlow.ReadWrite.All:

https://docs.microsoft.com/en-us/graph/api/identitycontainer-list-b2cuserflows?view=graph-rest-beta&tabs=csharp

image

but Azure CLI's Directory.AccessAsUser.All delegated permission is not sufficient. This causes failure:

AADSTS65002: Consent between first party application '04b07795-8ddb-461a-bbee-02f9e1bf7b46' and first party resource '00000003-0000-0000-c000-000000000000' must be configured via preauthorization - applications owned and operated by Microsoft must get approval from the API owner before requesting tokens for that API.

@jiasli
Copy link
Member Author

jiasli commented Sep 16, 2022

Workaround: Use service principal instead of user login

  1. Create your own application and service principal
  2. Give the application Application Permission IdentityUserFlow.Read.All, IdentityUserFlow.ReadWrite.All
  3. Log in to Azure CLI with that service principal: https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli#sign-in-with-a-service-principal

@kthejoker
Copy link

What if a user doesn't have permission to create a service principal?

This exact same flow worked fine in October of 2022. A user could use a DeviceCodeCredential and then access the Databricks scope with their own tokens.

Now I have to create an SP?

@jiasli
Copy link
Member Author

jiasli commented Feb 9, 2024

Azure CLI's first party application 04b07795-8ddb-461a-bbee-02f9e1bf7b46 is currently registered with below Microsoft Graph delegated permissions:

  • AuditLog.Read.All
  • Directory.AccessAsUser.All
  • Group.ReadWrite.All
  • User.ReadWrite.All
  • openid

This can be observed in the access token retrieved from

az account get-access-token --scope https://graph.microsoft.com/.default

The access token contains the below scp claim:

  "scp": "AuditLog.Read.All Directory.AccessAsUser.All email Group.ReadWrite.All openid profile User.ReadWrite.All",

@jiasli
Copy link
Member Author

jiasli commented Feb 9, 2024

This exact same flow worked fine in October of 2022. A user could use a DeviceCodeCredential and then access the Databricks scope with their own tokens.

@kthejoker, There is no DeviceCodeCredential concept in Azure CLI. Are you referring to az login --use-device-code? If so and you are seeing failure, that indicates your tenant may now have a Conditional Access policy that blocks accessing Databricks scope with Azure CLI's client ID and device code flow.

Now I have to create an SP?

Yes.

What if a user doesn't have permission to create a service principal?

You need to work with your tenant admin to either

  • Unblock accessing Databricks scope with Azure CLI's client ID and device code flow
  • Create a service principal

@cveld
Copy link

cveld commented Jun 11, 2024

Today I started a project to configure PIM using terraform using the azuread provider's resource azuread_group_role_management_policy. This requires
RoleManagementPolicy.ReadWrite.AzureADGroup. I am not a great fan of your suggested workaround to introduce a service principal as we work with secret-free service principals.
It seems either the required permission scopes are to be added to the first party app registration, or the custom client id should be introduced.

@cveld
Copy link

cveld commented Jul 9, 2024

@jiasli is there any plan to extend the permission scopes on the first party app registration 04b07795-8ddb-461a-bbee-02f9e1bf7b46? Any reason why you are keeping this a limited range? In the meanwhile the msgraph cli app registration did get the additional scopes. Although that is what I am assuming as the msgraph cli is capable of user delegated access to PIM related operations.

@jiasli
Copy link
Member Author

jiasli commented Oct 22, 2024

#30149 is another issue about Azure CLI's lack of PrivilegedAssignmentSchedule.ReadWrite.AzureADGroup or PrivilegedAssignmentSchedule.Remove.AzureADGroup delegated permission to call Create assignmentScheduleRequest API.

@jiasli
Copy link
Member Author

jiasli commented Oct 22, 2024

I retrieved an access token from Graph Explorer and decoded it at https://jwt.ms/ by clicking the {} button:

Image

The decoded claims contain:

  "app_displayname": "Graph Explorer",
  "appid": "de8bc8b5-d9f9-48b1-a8ad-b748da725064",

scp claim is

Calendars.ReadWrite
Contacts.ReadWrite
DeviceManagementApps.ReadWrite.All
DeviceManagementConfiguration.Read.All
DeviceManagementConfiguration.ReadWrite.All
DeviceManagementManagedDevices.PrivilegedOperations.All
DeviceManagementManagedDevices.Read.All
DeviceManagementManagedDevices.ReadWrite.All
DeviceManagementRBAC.Read.All
DeviceManagementRBAC.ReadWrite.All
DeviceManagementServiceConfig.Read.All
DeviceManagementServiceConfig.ReadWrite.All
Directory.AccessAsUser.All
Directory.ReadWrite.All
Files.ReadWrite.All
Group.ReadWrite.All
IdentityRiskEvent.Read.All
Mail.ReadWrite
MailboxSettings.ReadWrite
Notes.ReadWrite.All
openid
People.Read
Policy.Read.All
Presence.Read
Presence.Read.All
profile
Reports.Read.All
Sites.ReadWrite.All
Tasks.ReadWrite
User.Read
User.ReadBasic.All
User.ReadWrite
User.ReadWrite.All
email

Apparently, Graph Explorer's first party app has far more delegated permissions than Azure CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants