-
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
A new resource to assign scopes (delegated oauth permissions) for an application #591
Comments
|
That's actually the case for us! We use B2C, I forgot to mention that as that is probably why it does not work, thanks for noting, so it is probably not msgraph problem, but B2C problem |
Just a note to mirror my comments on the related issue #595 - I don't believe pre-authorized applications are related to this. I don't believe there is support for programmatic authorization of consent requests for delegated permissions. App role assignments work with service principals and therefore application permissions (roles), but delegated permissions (scopes) have their own interactive consent workflows, which, for high-level permissions, require involvement from an administrator. For example, there is a dedicated endpoint that applications can use to have admins consent to the permissions they need and this can be built into your application(s). Each tenant also has an Admin Consent Request Policy (this is something we could implement, please open a feature request if you're interested!) which specifies who will be notified by email for consent requests and how often. As such, this is a platform limitation which we aren't in a position to implement until such a time as programmatic access to this feature might be released. I would suggest reaching out via your support channels to let Microsoft know you are interested in this! Accordingly, as this isn't a viable feature for the provider, I'm going to close this one for now. Thanks! |
Hi @manicminer, I'm pretty sure there already is programmatic access to this feature. Please take a look at the oAuth2PermissionGrant resource type. I currently use this module as a workaround, as if it's said resource in the title of this issue: variable "resource_service_principal_object_id" {
type = string
}
variable "client_service_principal_object_id" {
type = string
}
variable "scope" {
type = string
}
variable "azure_config_dir" {
type = string
}
resource "null_resource" "consent" {
triggers = {
resource = var.resource_service_principal_object_id
client = var.client_service_principal_object_id
scope = var.scope
}
provisioner "local-exec" {
command = <<-GRANTCONSENTCMD
az rest --method POST \
--uri 'https://graph.microsoft.com/v1.0/oauth2PermissionGrants' \
--headers 'Content-Type=application/json' \
--body '{
"clientId": "${self.triggers.client}",
"consentType": "AllPrincipals",
"resourceId": "${self.triggers.resource}",
"scope": "${self.triggers.scope}"
}'
GRANTCONSENTCMD
interpreter = ["bash", "-c"]
environment = {
AZURE_CONFIG_DIR = var.azure_config_dir
}
}
} p.s. coming from the OIDC spec, I very much dislike the MS API terminology. |
MS API terminology is all but consistent as they use different names in GUI/API/CLI, but that' what we have to live with. You can check this command @dvdvorle , it's simpler than calling
I have also figured out that Azure has some cache and had to make sleep 30 before this command to make sure app is created before the command is ran. |
Thanks @ilya-git, that's what I was using before! But that command still uses the old aad graph api under the hood. The resource I linked to is part of the newer ms graph api, so I think that's what @manicminer was looking for. |
@dvdvorle Thanks! I stand corrected 🙇 In that case, marking this is a feature request and we'll be happy to implement this :) |
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
Description
The provider has a new resources now that is called
azuread_app_role_assignment
. It is now possible to grant app role assignments, but it does not seem to work with scopes. As this issue mentions, we can only create "request" for the required access usingrequired_resource_access
. And while it does now work for type "Role", there is still now way that I have found to do the same for the "Scope" (I have tried withazuread_app_role_assignment
and it fails).New or Affected Resource(s)
Potential Terraform Configuration
It seems that
azuread_application_pre_authorized
can be used for this purpose, but it did not work for me in the case of Microsoft graph with this error:References
The text was updated successfully, but these errors were encountered: