mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 10:28:22 +00:00
Update inject-identity.ts
This commit is contained in:
@@ -99,7 +99,6 @@ export const injectIdentity = fp(async (server: FastifyZodProvider) => {
|
|||||||
if (!authMode) return;
|
if (!authMode) return;
|
||||||
|
|
||||||
switch (authMode) {
|
switch (authMode) {
|
||||||
// May or may not have an orgId. If it doesn't have an org ID, it's likely because the token is from an org that doesn't enforce org-level auth.
|
|
||||||
case AuthMode.JWT: {
|
case AuthMode.JWT: {
|
||||||
const { user, tokenVersionId, orgId } = await server.services.authToken.fnValidateJwtIdentity(token);
|
const { user, tokenVersionId, orgId } = await server.services.authToken.fnValidateJwtIdentity(token);
|
||||||
req.auth = { authMode: AuthMode.JWT, user, userId: user.id, tokenVersionId, actor, orgId };
|
req.auth = { authMode: AuthMode.JWT, user, userId: user.id, tokenVersionId, actor, orgId };
|
||||||
@@ -117,7 +116,6 @@ export const injectIdentity = fp(async (server: FastifyZodProvider) => {
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Will always contain an orgId.
|
|
||||||
case AuthMode.SERVICE_TOKEN: {
|
case AuthMode.SERVICE_TOKEN: {
|
||||||
const serviceToken = await server.services.serviceToken.fnValidateServiceToken(token);
|
const serviceToken = await server.services.serviceToken.fnValidateServiceToken(token);
|
||||||
req.auth = {
|
req.auth = {
|
||||||
@@ -128,13 +126,11 @@ export const injectIdentity = fp(async (server: FastifyZodProvider) => {
|
|||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Will never contain an orgId. API keys are not tied to an organization.
|
|
||||||
case AuthMode.API_KEY: {
|
case AuthMode.API_KEY: {
|
||||||
const user = await server.services.apiKey.fnValidateApiKey(token as string);
|
const user = await server.services.apiKey.fnValidateApiKey(token as string);
|
||||||
req.auth = { authMode: AuthMode.API_KEY as const, userId: user.id, actor, user };
|
req.auth = { authMode: AuthMode.API_KEY as const, userId: user.id, actor, user };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// OK
|
|
||||||
case AuthMode.SCIM_TOKEN: {
|
case AuthMode.SCIM_TOKEN: {
|
||||||
const { orgId, scimTokenId } = await server.services.scim.fnValidateScimToken(token);
|
const { orgId, scimTokenId } = await server.services.scim.fnValidateScimToken(token);
|
||||||
req.auth = { authMode: AuthMode.SCIM_TOKEN, actor, scimTokenId, orgId };
|
req.auth = { authMode: AuthMode.SCIM_TOKEN, actor, scimTokenId, orgId };
|
||||||
|
|||||||
Reference in New Issue
Block a user