diff --git a/packages/core/src/routes/init.ts b/packages/core/src/routes/init.ts index 7ef917d32..602940434 100644 --- a/packages/core/src/routes/init.ts +++ b/packages/core/src/routes/init.ts @@ -15,9 +15,9 @@ import sessionRoutes from '@/routes/session/session'; import sessionSocialRoutes from '@/routes/session/social'; import settingRoutes from '@/routes/setting'; import signInExperiencesRoutes from '@/routes/sign-in-experience'; -import signInSettingsRoutes from '@/routes/sign-in-settings'; import statusRoutes from '@/routes/status'; import swaggerRoutes from '@/routes/swagger'; +import wellKnownRoutes from '@/routes/well-known'; import adminUserRoutes from './admin-user'; import logRoutes from './log'; @@ -49,7 +49,7 @@ const createRouters = (provider: Provider) => { meRoutes(meRouter); const anonymousRouter: AnonymousRouter = new Router(); - signInSettingsRoutes(anonymousRouter, provider); + wellKnownRoutes(anonymousRouter, provider); statusRoutes(anonymousRouter); // The swagger.json should contain all API routers. swaggerRoutes(anonymousRouter, [sessionRouter, managementRouter, meRouter, anonymousRouter]); diff --git a/packages/core/src/routes/sign-in-settings.test.ts b/packages/core/src/routes/well-known.test.ts similarity index 92% rename from packages/core/src/routes/sign-in-settings.test.ts rename to packages/core/src/routes/well-known.test.ts index c19bb1e9d..f8e19bf9b 100644 --- a/packages/core/src/routes/sign-in-settings.test.ts +++ b/packages/core/src/routes/well-known.test.ts @@ -15,7 +15,7 @@ import { import { getConnectorInstanceById } from '@/connectors'; import RequestError from '@/errors/RequestError'; import * as signInExperienceQueries from '@/queries/sign-in-experience'; -import signInSettingsRoutes from '@/routes/sign-in-settings'; +import wellKnownRoutes from '@/routes/well-known'; import { createRequester } from '@/utils/test-utils'; const getConnectorInstances = jest.fn(async () => [ @@ -58,13 +58,13 @@ jest.mock('oidc-provider', () => ({ })), })); -describe('GET /sign-in-settings', () => { +describe('GET /.well-known/sign-in-exp', () => { afterEach(() => { jest.clearAllMocks(); }); const sessionRequest = createRequester({ - anonymousRoutes: signInSettingsRoutes, + anonymousRoutes: wellKnownRoutes, provider: new Provider(''), middlewares: [ async (ctx, next) => { @@ -81,7 +81,7 @@ describe('GET /sign-in-settings', () => { .mockResolvedValue(mockSignInExperience); it('should return github and facebook connector instances', async () => { - const response = await sessionRequest.get('/sign-in-settings'); + const response = await sessionRequest.get('/.well-known/sign-in-exp'); expect(signInExperienceQuerySpyOn).toHaveBeenCalledTimes(1); expect(response.status).toEqual(200); expect(response.body).toMatchObject( @@ -111,7 +111,7 @@ describe('GET /sign-in-settings', () => { it('should return admin console settings', async () => { interactionDetails.mockResolvedValue({ params: { client_id: adminConsoleApplicationId } }); - const response = await sessionRequest.get('/sign-in-settings'); + const response = await sessionRequest.get('/.well-known/sign-in-exp'); expect(signInExperienceQuerySpyOn).toHaveBeenCalledTimes(1); expect(response.status).toEqual(200); diff --git a/packages/core/src/routes/sign-in-settings.ts b/packages/core/src/routes/well-known.ts similarity index 94% rename from packages/core/src/routes/sign-in-settings.ts rename to packages/core/src/routes/well-known.ts index 3d71b7dc8..28e6c0a25 100644 --- a/packages/core/src/routes/sign-in-settings.ts +++ b/packages/core/src/routes/well-known.ts @@ -15,12 +15,9 @@ import { hasActiveUsers } from '@/queries/user'; import { AnonymousRouter } from './types'; -export default function signInSettingsRoutes( - router: T, - provider: Provider -) { +export default function wellKnownRoutes(router: T, provider: Provider) { router.get( - '/sign-in-settings', + '/.well-known/sign-in-exp', async (ctx, next) => { const [signInExperience, connectorInstances, interaction] = await Promise.all([ findDefaultSignInExperience(), diff --git a/packages/ui/src/apis/settings.ts b/packages/ui/src/apis/settings.ts index 188c56376..edd3e7a82 100644 --- a/packages/ui/src/apis/settings.ts +++ b/packages/ui/src/apis/settings.ts @@ -7,5 +7,5 @@ import { SignInExperience } from '@logto/schemas'; import ky from 'ky'; export const getSignInExperience = async (): Promise => { - return ky.get('/api/sign-in-settings').json(); + return ky.get('/api/.well-known/sign-in-exp').json(); };