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

data.auth0_resource_server cannot read scopes for Auth0 management API #547

Closed
6 tasks done
sergei-ivanov opened this issue Apr 3, 2023 · 2 comments
Closed
6 tasks done
Labels
🪲 bug Something isn't working

Comments

@sergei-ivanov
Copy link

sergei-ivanov commented Apr 3, 2023

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have upgraded to the latest version of this provider and the issue still persists.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

It's not possible to read the list of scopes for Auth0 Management API using auth0_resource_server data source.

It looks like auth0_resource_server data source reuses the read logic from the sibling auth0_resource_server resource, which explicitly skips reading scopes for Auth0 Management API:

if resourceServer.GetName() != auth0ManagementAPI {
result = multierror.Append(
result,
d.Set("verification_location", resourceServer.GetVerificationLocation()),
d.Set("options", resourceServer.GetOptions()),
d.Set("enforce_policies", resourceServer.GetEnforcePolicies()),
d.Set("token_dialect", resourceServer.GetTokenDialect()),
d.Set("scopes", flattenResourceServerScopes(resourceServer.GetScopes())),
)
}

Expectation

It should be possible to retrieve the list of scopes for Auth0 Management API.

Reproduction

I was trying to create a machine-to-machine client with access to Auth0 Management API. I was hoping to retrieve the list of scopes from the data source as below, but it looks like for the time being I'll have to list them explicitly and manually.

data "auth0_resource_server" "auth0_management_api" {
  identifier = "https://${var.auth0_domain}/api/v2/"
}

resource "auth0_client" "m2m" {
  app_type                   = "non_interactive"
  # ...
}

resource "auth0_client_grant" "m2m_auth0_management_api" {
  client_id = auth0_client.m2m.id
  audience  = data.auth0_resource_server.auth0_management_api.identifier
  scope     = data.auth0_resource_server.auth0_management_api.scopes[*].value
}

When I output the value of data.auth0_resource_server.auth0_management_api, I can see that scopes is an empty set.

Auth0 Terraform Provider version

0.45.0

Terraform version

1.3.7

@sergiught
Copy link
Contributor

Hey @sergei-ivanov thanks for reporting this! I have a fix in #555. I'll circle back here when we're able to get that merged and released.

@sergiught
Copy link
Contributor

Thanks again @sergei-ivanov for raising this. It is now available within the latest https://github.com/auth0/terraform-provider-auth0/releases/tag/v0.46.0. Please let us know if you have any issues with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants