You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: accept a scheme and trailing slash in ManagementApiBuilder.domain() - #946
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.
One security/behavior question on the normalization: getBaseUrl() now preserves an explicit http:// scheme. That value is used both for the Management API environment and as the base URL passed to OAuthTokenSupplier, so domain("http://...") will send API requests and the client-credentials request over cleartext. The reported compatibility case asks for an explicit https:// or a bare domain, and the prior domain() path always selected HTTPS. Could this helper reject http:// (or normalize to HTTPS), leaving an intentionally insecure test/local URL to the explicit url() / environment() configuration? If HTTP support is deliberate, a small synthetic regression test and explicit documentation would make that security tradeoff clear. This is based on the captured source/diff only; I did not use a tenant, real credentials, or a live API.
The http:// handling matches AuthAPI.createBaseUrl(), which keeps an explicit http:// or https:// scheme and adds https:// only to a bare domain. Before this change, domain("http://...") didn't select HTTPS either: it built https://http://..., which isn't a valid URL. A bare domain or https:// still gives the same HTTPS URLs as before.
If the maintainers prefer domain() to reject http:// and leave plain HTTP to environment(), that's a small change to getBaseUrl() plus a test.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
ManagementApiBuilder.domain()prependedhttps://and appended/api/v2to the value as given. A domain such ashttps://my-tenant.auth0.comormy-tenant.auth0.com/produced an invalid Management API URL, an invalid token URL, and an invalid default audience for the client credentials flow.AuthAPIaccepts both forms, and so didManagementAPIin 2.x.ManagementApiBuilder.getBaseUrl()now removes trailing slashes from the domain and addshttps://only when the domain has nohttps://orhttp://scheme, matchingAuthAPI.ManagementApiBuilder.setEnvironment()builds the API URL fromgetBaseUrl(), so the API URL, token URL, and default audience use the same normalized value.domain()Javadoc states that a leadinghttps://and a trailing slash are accepted.ManagementApiBuilderTestused 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.comproduces the same URLs as before.References
Fixes #945
Testing
New tests in
ManagementApiBuilderTest:testDomainUrls: a bare domain produceshttps://my-tenant.auth0.comandhttps://my-tenant.auth0.com/api/v2.testDomainWithSchemeAndTrailingSlash:https://my-tenant.auth0.com/produces the same URLs. This test fails without the fix.Checklist