-
Notifications
You must be signed in to change notification settings - Fork 301
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
azuread_application bug: oauth2_permission_scope & app_role duplicate id #963
Comments
@tsanton Thanks for looking into this, and for the PR. Sometimes a StackOverflow and self-experimentation is all we have to go on. I agree the provider isn't quite right here and the probable correct approach is to compare the IDs and values, since as you say at a minimum these are allowed to be the same across a role/scope combination. |
Hi @manicminer! I discovered that the assumption was wrong when testing the provider fix by creating an application without all matching fields. The following values must match for the 'oauth2Permissions' and 'appRoles' properties with identifier '<UUID>': (description, adminConsentDescription), (displayName, adminConsentDisplayName),(isEnabled,isEnabled),(origin, origin),(value, value). Ensure that you are intending to have entries with the same identifier, and if so, are updating them together Therefor I expanded the validation to compare these values -> I also added the 400 response as the error message in the provider. |
@tsanton Ah ok, that's great thanks for updating it. I'll review the PR shortly 👍 |
@tsanton Just checking whether you were able to update the PR to validate across all fields? Thanks. |
@manicminer I implemented the initial PR with validation across (almost) all fields. Here is the struct that I'm utilising for validation. type appPermission struct {
id string
displayName string
description string
enabled bool
value string
} I've left out the scope.origin == role.origin because of: Specifies if the app role is defined on the application] object or on the servicePrincipal entity. Must not be included in any POST or PATCH requests. Read-only. docs: https://learn.microsoft.com/en-us/graph/api/resources/approle?view=graph-rest-1.0#properties Would you like me to add the origin field to the validation? |
I re-read the diff and I see now, I missed the DeepEqual comparison :) We can ignore the origin field for validation purposes. |
Just checked: the With other words: the PR is complete :) |
This functionality has been released in v2.32.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Community Note
Terraform (and AzureAD Provider) Version
Affected Resource(s)
azuread_application
Debug Output
Expected Behavior
Terraform should be able to create/update an app registration to contain both and app_role (ar) and a oauth2_permission_scope (ops) given that:
Actual Behavior
Terraform errors out with duplicate id warning.
Important Factoids
Below you'll find a redacted version of my application manifest. I manually altered and added the app_role with displayName == "Read access", enabling both delegated and application auth flows to access my API with the correct permission (scp & roles).
The root cause of the problem seem to come from applicationValidateRolesScopes:
It's not enough to validate unique id's; we must at minimum allow overlapping id & value pairs in both slices.
Ideally(?) we should validate that all attributes are equal between scope and role on matching id & value. Don't have docs on this (and haven't tested different display names and description values) as I blindly trusted this SO answer (and it worked).
Further we must update the documentation for the azuread_application. It claims that:
This is not the case. Given the condition that all common fields in both objects match they can indeed overlap.
The text was updated successfully, but these errors were encountered: