Skip to content

Commit

Permalink
Remove callback route default
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath committed Feb 1, 2021
1 parent 8f2e6ab commit a52b686
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/auth0-session/get-config.ts
Expand Up @@ -133,7 +133,7 @@ const paramsSchema = Joi.object({
issuerBaseURL: Joi.string().uri().required(),
legacySameSiteCookie: Joi.boolean().optional().default(true),
routes: Joi.object({
callback: Joi.string().uri({ relativeOnly: true }).default('/callback'),
callback: Joi.string().uri({ relativeOnly: true }).required(),
postLogoutRedirect: Joi.string().uri({ allowRelative: true }).default('')
})
.default()
Expand Down
5 changes: 4 additions & 1 deletion tests/auth0-session/client.test.ts
Expand Up @@ -11,7 +11,10 @@ const defaultConfig = {
clientID: '__test_client_id__',
clientSecret: '__test_client_secret__',
issuerBaseURL: 'https://op.example.com',
baseURL: 'https://example.org'
baseURL: 'https://example.org',
routes: {
callback: '/callback'
}
};

const getClient = (params: ConfigParameters = {}): Promise<Client> =>
Expand Down
5 changes: 4 additions & 1 deletion tests/auth0-session/config.test.ts
Expand Up @@ -4,7 +4,10 @@ const defaultConfig = {
secret: '__test_session_secret__',
clientID: '__test_client_id__',
issuerBaseURL: 'https://op.example.com',
baseURL: 'https://example.org'
baseURL: 'https://example.org',
routes: {
callback: '/callback'
}
};

const validateAuthorizationParams = (authorizationParams: DeepPartial<AuthorizationParameters>): Config =>
Expand Down
5 changes: 4 additions & 1 deletion tests/auth0-session/fixtures/helpers.ts
Expand Up @@ -11,7 +11,10 @@ const clientId = '__test_client_id__';
export const defaultConfig: Omit<ConfigParameters, 'baseURL'> = {
secret,
clientID: clientId,
issuerBaseURL: 'https://op.example.com'
issuerBaseURL: 'https://op.example.com',
routes: {
callback: '/callback'
}
};

export const toSignedCookieJar = (cookies: { [key: string]: string }, url: string): CookieJar => {
Expand Down
2 changes: 1 addition & 1 deletion tests/auth0-session/handlers/logout.test.ts
Expand Up @@ -115,7 +115,7 @@ describe('logout route', () => {

it('should redirect to postLogoutRedirect', async () => {
const postLogoutRedirect = 'https://example.com/post-logout';
const baseURL = await setup({ ...defaultConfig, routes: { postLogoutRedirect } });
const baseURL = await setup({ ...defaultConfig, routes: { ...defaultConfig.routes, postLogoutRedirect } });
const cookieJar = await login(baseURL);

const session: SessionResponse = await get(baseURL, '/session', { cookieJar });
Expand Down
8 changes: 7 additions & 1 deletion tests/fixtures/default-settings.ts
Expand Up @@ -5,7 +5,10 @@ export const withoutApi: ConfigParameters = {
clientID: '__test_client_id__',
clientSecret: 'client_secret',
baseURL: 'http://www.acme.com/',
secret: '__test_session_secret__'
secret: '__test_session_secret__',
routes: {
callback: '/api/auth/callback'
}
};

/**
Expand All @@ -20,5 +23,8 @@ export const withApi: ConfigParameters = {
authorizationParams: {
scope: 'openid profile read:customer',
audience: 'https://api.acme.com'
},
routes: {
callback: '/api/auth/callback'
}
};

0 comments on commit a52b686

Please sign in to comment.