Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: added deprecated endpoint back for backwards compatibility

Piyush Guptaf6d24a63af04
diff --git a/backend/src/server/routes/v1/identity-token-auth-router.ts b/backend/src/server/routes/v1/identity-token-auth-router.ts
index ff45778b64..77eb8768b3 100644
--- a/backend/src/server/routes/v1/identity-token-auth-router.ts
+++ b/backend/src/server/routes/v1/identity-token-auth-router.ts
@@ -408,6 +408,60 @@ export const registerIdentityTokenAuthRouter = async (server: FastifyZodProvider
}
});
+ // deprecated - use the GET /token-auth/tokens/:tokenId instead, this endpoint will be removed in the future
+ server.route({
+ method: "GET",
+ url: "/token-auth/identities/:identityId/tokens/:tokenId",
+ config: {
+ rateLimit: readLimit
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ schema: {
+ hide: false,
+ tags: [ApiDocsTags.TokenAuth],
+ description: "Get token for machine identity with Token Auth",
+ security: [
+ {
+ bearerAuth: []
+ }
+ ],
+ params: z.object({
+ identityId: z.string().describe(TOKEN_AUTH.GET_TOKEN.identityId),
+ tokenId: z.string().describe(TOKEN_AUTH.GET_TOKEN.tokenId)
+ }),
+ response: {
+ 200: z.object({
+ token: IdentityAccessTokensSchema
+ })
+ }
+ },
+ handler: async (req) => {
+ const { token, identityMembershipOrg } = await server.services.identityTokenAuth.getTokenAuthTokenById({
+ tokenId: req.params.tokenId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorOrgId: req.permission.orgId,
+ actorAuthMethod: req.permission.authMethod,
+ isActorSuperAdmin: isSuperAdmin(req.auth)
+ });
+
+ await server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ orgId: identityMembershipOrg.scopeOrgId,
+ event: {
+ type: EventType.GET_TOKEN_IDENTITY_TOKEN_AUTH,
+ metadata: {
+ identityId: token.identityId,
+ identityName: identityMembershipOrg.identity.name,
+ tokenId: token.id
+ }
+ }
+ });
+
+ return { token };
+ }
+ });
+
server.route({
method: "GET",
url: "/token-auth/tokens/:tokenId",