Skip to content

Commit

Permalink
Fix Configuration URL when using __tenantInfo and a baseConfiguration…
Browse files Browse the repository at this point in the history
…URL (#1425)

ZD Num: 43661

This generates the right configuration URL when a `baseConfigurationUrl` is set and Tenant Info is being used.

Fixes #1417
  • Loading branch information
lbalmaceda authored and luisrudge committed Jul 4, 2018
1 parent 8cebda3 commit adfc8a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit adfc8a8

Please sign in to comment.