mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
refactor(core): remove subject token api prefix (#6235)
This commit is contained in:
parent
dd4ae57a98
commit
c5897b3893
6 changed files with 14 additions and 12 deletions
|
@ -34,10 +34,10 @@ import resourceRoutes from './resource.js';
|
||||||
import resourceScopeRoutes from './resource.scope.js';
|
import resourceScopeRoutes from './resource.scope.js';
|
||||||
import roleRoutes from './role.js';
|
import roleRoutes from './role.js';
|
||||||
import roleScopeRoutes from './role.scope.js';
|
import roleScopeRoutes from './role.scope.js';
|
||||||
import securityRoutes from './security/index.js';
|
|
||||||
import signInExperiencesRoutes from './sign-in-experience/index.js';
|
import signInExperiencesRoutes from './sign-in-experience/index.js';
|
||||||
import ssoConnectors from './sso-connector/index.js';
|
import ssoConnectors from './sso-connector/index.js';
|
||||||
import statusRoutes from './status.js';
|
import statusRoutes from './status.js';
|
||||||
|
import subjectTokenRoutes from './subject-token.js';
|
||||||
import swaggerRoutes from './swagger/index.js';
|
import swaggerRoutes from './swagger/index.js';
|
||||||
import systemRoutes from './system.js';
|
import systemRoutes from './system.js';
|
||||||
import type { AnonymousRouter, ManagementApiRouter } from './types.js';
|
import type { AnonymousRouter, ManagementApiRouter } from './types.js';
|
||||||
|
@ -89,7 +89,7 @@ const createRouters = (tenant: TenantContext) => {
|
||||||
organizationRoutes(managementRouter, tenant);
|
organizationRoutes(managementRouter, tenant);
|
||||||
ssoConnectors(managementRouter, tenant);
|
ssoConnectors(managementRouter, tenant);
|
||||||
systemRoutes(managementRouter, tenant);
|
systemRoutes(managementRouter, tenant);
|
||||||
securityRoutes(managementRouter, tenant);
|
subjectTokenRoutes(managementRouter, tenant);
|
||||||
|
|
||||||
const anonymousRouter: AnonymousRouter = new Router();
|
const anonymousRouter: AnonymousRouter = new Router();
|
||||||
wellKnownRoutes(anonymousRouter, tenant);
|
wellKnownRoutes(anonymousRouter, tenant);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
{
|
{
|
||||||
"tags": [
|
"tags": [
|
||||||
{
|
{
|
||||||
"name": "Security",
|
"name": "Subject tokens",
|
||||||
"description": "Security related endpoints."
|
"description": "The subject token API provides the ability to create a new subject token for the use of impersonating the user."
|
||||||
},
|
},
|
||||||
{ "name": "Dev feature" }
|
{ "name": "Dev feature" }
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"/api/security/subject-tokens": {
|
"/api/subject-tokens": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Create a new subject token.",
|
"summary": "Create a new subject token.",
|
||||||
"description": "Create a new subject token for the use of impersonating the user.",
|
"description": "Create a new subject token for the use of impersonating the user.",
|
|
@ -8,9 +8,11 @@ import { EnvSet } from '#src/env-set/index.js';
|
||||||
import koaGuard from '#src/middleware/koa-guard.js';
|
import koaGuard from '#src/middleware/koa-guard.js';
|
||||||
import koaQuotaGuard from '#src/middleware/koa-quota-guard.js';
|
import koaQuotaGuard from '#src/middleware/koa-quota-guard.js';
|
||||||
|
|
||||||
import { type RouterInitArgs, type ManagementApiRouter } from '../types.js';
|
import { type RouterInitArgs, type ManagementApiRouter } from './types.js';
|
||||||
|
|
||||||
export default function securityRoutes<T extends ManagementApiRouter>(...args: RouterInitArgs<T>) {
|
export default function subjectTokenRoutes<T extends ManagementApiRouter>(
|
||||||
|
...args: RouterInitArgs<T>
|
||||||
|
) {
|
||||||
const [
|
const [
|
||||||
router,
|
router,
|
||||||
{
|
{
|
||||||
|
@ -27,7 +29,7 @@ export default function securityRoutes<T extends ManagementApiRouter>(...args: R
|
||||||
}
|
}
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
'/security/subject-tokens',
|
'/subject-tokens',
|
||||||
koaQuotaGuard({ key: 'subjectTokenEnabled', quota }),
|
koaQuotaGuard({ key: 'subjectTokenEnabled', quota }),
|
||||||
koaGuard({
|
koaGuard({
|
||||||
body: object({
|
body: object({
|
|
@ -155,7 +155,7 @@ const identifiableEntityNames = Object.freeze([
|
||||||
const additionalTags = Object.freeze(
|
const additionalTags = Object.freeze(
|
||||||
condArray<string>(
|
condArray<string>(
|
||||||
'Organization applications',
|
'Organization applications',
|
||||||
EnvSet.values.isDevFeaturesEnabled && 'Security',
|
EnvSet.values.isDevFeaturesEnabled && 'Subject tokens',
|
||||||
'Organization users'
|
'Organization users'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,8 +25,8 @@ const methodToVerb = Object.freeze({
|
||||||
type RouteDictionary = Record<`${OpenAPIV3.HttpMethods} ${string}`, string>;
|
type RouteDictionary = Record<`${OpenAPIV3.HttpMethods} ${string}`, string>;
|
||||||
|
|
||||||
const devFeatureCustomRoutes: RouteDictionary = Object.freeze({
|
const devFeatureCustomRoutes: RouteDictionary = Object.freeze({
|
||||||
// Security
|
// Subject tokens
|
||||||
'post /security/subject-tokens': 'CreateSubjectToken',
|
'post /subject-tokens': 'CreateSubjectToken',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const customRoutes: Readonly<RouteDictionary> = Object.freeze({
|
export const customRoutes: Readonly<RouteDictionary> = Object.freeze({
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { authedAdminApi } from './api.js';
|
||||||
|
|
||||||
export const createSubjectToken = async (userId: string, context?: JsonObject) =>
|
export const createSubjectToken = async (userId: string, context?: JsonObject) =>
|
||||||
authedAdminApi
|
authedAdminApi
|
||||||
.post('security/subject-tokens', {
|
.post('subject-tokens', {
|
||||||
json: {
|
json: {
|
||||||
userId,
|
userId,
|
||||||
context,
|
context,
|
||||||
|
|
Loading…
Reference in a new issue