Skip to content

fix: accept a scheme and trailing slash in ManagementApiBuilder.domain() - #946

Open
RaphaelFakhri wants to merge 1 commit into
auth0:masterfrom
RaphaelFakhri:fix/mgmt-builder-domain-scheme
Open

RaphaelFakhri wants to merge 1 commit into
auth0:masterfrom
RaphaelFakhri:fix/mgmt-builder-domain-scheme

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Changes

ManagementApiBuilder.domain() prepended https:// and appended /api/v2 to the value as given. A domain such as https://my-tenant.auth0.com or my-tenant.auth0.com/ produced an invalid Management API URL, an invalid token URL, and an invalid default audience for the client credentials flow. AuthAPI accepts both forms, and so did ManagementAPI in 2.x.

  • ManagementApiBuilder.getBaseUrl() now removes trailing slashes from the domain and adds https:// only when the domain has no https:// or http:// scheme, matching AuthAPI.
  • ManagementApiBuilder.setEnvironment() builds the API URL from getBaseUrl(), so the API URL, token URL, and default audience use the same normalized value.
  • The domain() Javadoc states that a leading https:// and a trailing slash are accepted.
  • ManagementApiBuilderTest used JUnit 4 annotations, which the JUnit Platform runner in this build does not execute. The test class now uses JUnit Jupiter, so its existing tests and the new tests run.

No public API changes. A bare domain such as my-tenant.auth0.com produces the same URLs as before.

References

Fixes #945

Testing

New tests in ManagementApiBuilderTest:

  • testDomainUrls: a bare domain produces https://my-tenant.auth0.com and https://my-tenant.auth0.com/api/v2.
  • testDomainWithSchemeAndTrailingSlash: https://my-tenant.auth0.com/ produces the same URLs. This test fails without the fix.
./gradlew spotlessCheck test --tests com.auth0.client.mgmt.ManagementApiBuilderTest
  • This change adds test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 17, 2026 21:22

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ManagementApiBuilder.domain() builds an invalid URL when the domain includes https:// or a trailing slash

1 participant