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

Fix Configuration URL when using __tenantInfo and a baseConfigurationURL #1425

Merged
merged 1 commit into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,10 @@ function extractClientBaseUrlOption(opts, domain) {

export function extractTenantBaseUrlOption(opts, domain) {
if (opts.configurationBaseUrl && typeof opts.configurationBaseUrl === 'string') {
if (opts.overrides && opts.overrides.__tenant) {
// When using a custom domain and a configuration URL hosted in auth0's cdn
return urljoin(opts.configurationBaseUrl, 'tenants', 'v1', `${opts.overrides.__tenant}.js`);
}
return urljoin(opts.configurationBaseUrl, 'info-v1.js');
}

Expand Down
14 changes: 14 additions & 0 deletions test/tenantinfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ import expect from 'expect.js';
import { extractTenantBaseUrlOption } from '../src/core/index';

describe('extractTenantBaseUrlOption', () => {
it('should return the configurationBaseUrl with tenant in path', () => {
var url = extractTenantBaseUrlOption(
{
configurationBaseUrl: 'https://test.com',
overrides: {
__tenant: 'lbalmaceda'
}
},
'lbalmaceda.auth0.com'
);

expect(url).to.be('https://test.com/tenants/v1/lbalmaceda.js');
});

it('should return the configurationBaseUrl', () => {
var url = extractTenantBaseUrlOption(
{
Expand Down