mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 11:27:47 +00:00
Add user
This commit is contained in:
@@ -6,6 +6,8 @@ import { removeTrailingSlash } from "@app/lib/fn";
|
|||||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
import { AuthMode } from "@app/services/auth/auth-type";
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
|
|
||||||
|
import { sanitizedServiceTokenUserSchema } from "../sanitizedSchemas";
|
||||||
|
|
||||||
export const sanitizedServiceTokenSchema = ServiceTokensSchema.omit({
|
export const sanitizedServiceTokenSchema = ServiceTokensSchema.omit({
|
||||||
secretHash: true,
|
secretHash: true,
|
||||||
encryptedKey: true,
|
encryptedKey: true,
|
||||||
@@ -20,15 +22,21 @@ export const registerServiceTokenRouter = async (server: FastifyZodProvider) =>
|
|||||||
onRequest: verifyAuth([AuthMode.SERVICE_TOKEN]),
|
onRequest: verifyAuth([AuthMode.SERVICE_TOKEN]),
|
||||||
schema: {
|
schema: {
|
||||||
response: {
|
response: {
|
||||||
200: ServiceTokensSchema.merge(z.object({ workspace: z.string() }))
|
200: ServiceTokensSchema.merge(
|
||||||
|
z.object({
|
||||||
|
workspace: z.string(),
|
||||||
|
user: sanitizedServiceTokenUserSchema
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const serviceTokenData = await server.services.serviceToken.getServiceToken({
|
const { serviceToken, user } = await server.services.serviceToken.getServiceToken({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
actor: req.permission.type
|
actor: req.permission.type
|
||||||
});
|
});
|
||||||
return { ...serviceTokenData, workspace: serviceTokenData.projectId };
|
|
||||||
|
return { ...serviceToken, workspace: serviceToken.projectId, user };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user