0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

chore(core): add dev feature guard to SSO endpoints (#4971)

* chore(core): guard sso api

guard sso api

* chore(core): guard sso interaction api

guard sso interaction api
This commit is contained in:
simeng-li 2023-11-27 16:56:55 +08:00 committed by GitHub
parent 528c6c462c
commit ccfad51e62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -3,6 +3,7 @@ import type Router from 'koa-router';
import { type IRouterParamContext } from 'koa-router'; import { type IRouterParamContext } from 'koa-router';
import { z } from 'zod'; import { z } from 'zod';
import { EnvSet } from '#src/env-set/index.js';
import RequestError from '#src/errors/RequestError/index.js'; import RequestError from '#src/errors/RequestError/index.js';
import { assignInteractionResults } from '#src/libraries/session.js'; import { assignInteractionResults } from '#src/libraries/session.js';
import { type WithLogContext } from '#src/middleware/koa-audit-log.js'; import { type WithLogContext } from '#src/middleware/koa-audit-log.js';
@ -28,6 +29,11 @@ export default function singleSignOnRoutes<T extends IRouterParamContext>(
router: Router<unknown, WithInteractionDetailsContext<WithLogContext<T>>>, router: Router<unknown, WithInteractionDetailsContext<WithLogContext<T>>>,
tenant: TenantContext tenant: TenantContext
) { ) {
// FIXME: @simeng-li should remove this check after the feature is enabled in production
if (!EnvSet.values.isDevFeaturesEnabled) {
return;
}
const { provider, libraries, queries } = tenant; const { provider, libraries, queries } = tenant;
const { ssoConnectors: ssoConnectorsLibrary } = libraries; const { ssoConnectors: ssoConnectorsLibrary } = libraries;

View file

@ -8,6 +8,7 @@ import { generateStandardShortId } from '@logto/shared';
import { conditional, assert } from '@silverhand/essentials'; import { conditional, assert } from '@silverhand/essentials';
import { z } from 'zod'; import { z } from 'zod';
import { EnvSet } from '#src/env-set/index.js';
import RequestError from '#src/errors/RequestError/index.js'; import RequestError from '#src/errors/RequestError/index.js';
import koaGuard from '#src/middleware/koa-guard.js'; import koaGuard from '#src/middleware/koa-guard.js';
import koaPagination from '#src/middleware/koa-pagination.js'; import koaPagination from '#src/middleware/koa-pagination.js';
@ -26,6 +27,11 @@ import {
} from './utils.js'; } from './utils.js';
export default function singleSignOnRoutes<T extends AuthedRouter>(...args: RouterInitArgs<T>) { export default function singleSignOnRoutes<T extends AuthedRouter>(...args: RouterInitArgs<T>) {
// FIXME: @simeng-li should remove this check after the feature is enabled in production
if (!EnvSet.values.isDevFeaturesEnabled) {
return;
}
const [ const [
router, router,
{ {