mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 07:26:45 +00:00
feat(infisical-pg): fixed ts issue on passport type change
This commit is contained in:
@@ -127,7 +127,7 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
|
|||||||
// this is due to zod type difference
|
// this is due to zod type difference
|
||||||
}) as any,
|
}) as any,
|
||||||
handler: (req, res) => {
|
handler: (req, res) => {
|
||||||
if (req.passportUser.isCompleted) {
|
if (req.passportUser.isUserCompleted) {
|
||||||
return res.redirect(
|
return res.redirect(
|
||||||
`${appCfg.SITE_URL}/login/sso?token=${encodeURIComponent(
|
`${appCfg.SITE_URL}/login/sso?token=${encodeURIComponent(
|
||||||
req.passportUser.providerAuthToken
|
req.passportUser.providerAuthToken
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ForbiddenError } from "@casl/ability";
|
|||||||
|
|
||||||
import { BadRequestError, InternalServerError } from "@app/lib/errors";
|
import { BadRequestError, InternalServerError } from "@app/lib/errors";
|
||||||
import { groupBy } from "@app/lib/fn";
|
import { groupBy } from "@app/lib/fn";
|
||||||
|
import { logger } from "@app/lib/logger";
|
||||||
import { TSecretDalFactory } from "@app/services/secret/secret-dal";
|
import { TSecretDalFactory } from "@app/services/secret/secret-dal";
|
||||||
import { TSecretVersionDalFactory } from "@app/services/secret/secret-version-dal";
|
import { TSecretVersionDalFactory } from "@app/services/secret/secret-version-dal";
|
||||||
import { TSecretFolderDalFactory } from "@app/services/secret-folder/secret-folder-dal";
|
import { TSecretFolderDalFactory } from "@app/services/secret-folder/secret-folder-dal";
|
||||||
@@ -19,7 +20,6 @@ import {
|
|||||||
import { TSnapshotDalFactory } from "./snapshot-dal";
|
import { TSnapshotDalFactory } from "./snapshot-dal";
|
||||||
import { TSnapshotFolderDalFactory } from "./snapshot-folder-dal";
|
import { TSnapshotFolderDalFactory } from "./snapshot-folder-dal";
|
||||||
import { TSnapshotSecretDalFactory } from "./snapshot-secret-dal";
|
import { TSnapshotSecretDalFactory } from "./snapshot-secret-dal";
|
||||||
import { logger } from "@app/lib/logger";
|
|
||||||
|
|
||||||
type TSecretSnapshotServiceFactoryDep = {
|
type TSecretSnapshotServiceFactoryDep = {
|
||||||
snapshotDal: TSnapshotDalFactory;
|
snapshotDal: TSnapshotDalFactory;
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
|
|||||||
authMethod: AuthMethod.GITLAB,
|
authMethod: AuthMethod.GITLAB,
|
||||||
callbackPort: req.query.state as string
|
callbackPort: req.query.state as string
|
||||||
});
|
});
|
||||||
console.log({ isUserCompleted, providerAuthToken });
|
|
||||||
|
|
||||||
return cb(null, { isUserCompleted, providerAuthToken });
|
return cb(null, { isUserCompleted, providerAuthToken });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export const registerSignupRouter = async (server: FastifyZodProvider) => {
|
|||||||
...req.body,
|
...req.body,
|
||||||
ip: req.realIp,
|
ip: req.realIp,
|
||||||
userAgent,
|
userAgent,
|
||||||
authorization: req.headers.authorization
|
authorization: req.headers.authorization as string
|
||||||
});
|
});
|
||||||
|
|
||||||
res.setCookie("jid", refreshToken, {
|
res.setCookie("jid", refreshToken, {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import { getConfig } from "@app/lib/config/env";
|
|
||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
|
|
||||||
|
import { getConfig } from "@app/lib/config/env";
|
||||||
|
import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AuthModeProviderJwtTokenPayload,
|
AuthModeProviderJwtTokenPayload,
|
||||||
AuthModeProviderSignUpTokenPayload,
|
AuthModeProviderSignUpTokenPayload,
|
||||||
AuthTokenType
|
AuthTokenType
|
||||||
} from "./auth-type";
|
} from "./auth-type";
|
||||||
import { BadRequestError, UnauthorizedError } from "@app/lib/errors";
|
|
||||||
|
|
||||||
export const validateProviderAuthToken = (providerToken: string, email: string) => {
|
export const validateProviderAuthToken = (providerToken: string, email: string) => {
|
||||||
if (!providerToken) throw new UnauthorizedError();
|
if (!providerToken) throw new UnauthorizedError();
|
||||||
@@ -15,7 +17,6 @@ export const validateProviderAuthToken = (providerToken: string, email: string)
|
|||||||
appCfg.JWT_AUTH_SECRET
|
appCfg.JWT_AUTH_SECRET
|
||||||
) as AuthModeProviderJwtTokenPayload;
|
) as AuthModeProviderJwtTokenPayload;
|
||||||
|
|
||||||
console.log(decodedToken);
|
|
||||||
if (decodedToken.authTokenType !== AuthTokenType.PROVIDER_TOKEN) throw new UnauthorizedError();
|
if (decodedToken.authTokenType !== AuthTokenType.PROVIDER_TOKEN) throw new UnauthorizedError();
|
||||||
if (decodedToken.email !== email) throw new Error("Invalid auth credentials");
|
if (decodedToken.email !== email) throw new Error("Invalid auth credentials");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { TAuthTokenServiceFactory } from "../auth-token/auth-token-service";
|
|||||||
import { TokenType } from "../auth-token/auth-token-types";
|
import { TokenType } from "../auth-token/auth-token-types";
|
||||||
import { SmtpTemplates, TSmtpService } from "../smtp/smtp-service";
|
import { SmtpTemplates, TSmtpService } from "../smtp/smtp-service";
|
||||||
import { TUserDalFactory } from "../user/user-dal";
|
import { TUserDalFactory } from "../user/user-dal";
|
||||||
|
import { validateProviderAuthToken } from "./auth-fns";
|
||||||
import {
|
import {
|
||||||
TLoginClientProofDTO,
|
TLoginClientProofDTO,
|
||||||
TLoginGenServerPublicKeyDTO,
|
TLoginGenServerPublicKeyDTO,
|
||||||
@@ -16,7 +17,6 @@ import {
|
|||||||
TVerifyMfaTokenDTO
|
TVerifyMfaTokenDTO
|
||||||
} from "./auth-login-type";
|
} from "./auth-login-type";
|
||||||
import { AuthMethod, AuthTokenType } from "./auth-type";
|
import { AuthMethod, AuthTokenType } from "./auth-type";
|
||||||
import { validateProviderAuthToken } from "./auth-fns";
|
|
||||||
|
|
||||||
type TAuthLoginServiceFactoryDep = {
|
type TAuthLoginServiceFactoryDep = {
|
||||||
userDal: TUserDalFactory;
|
userDal: TUserDalFactory;
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import { TOrgServiceFactory } from "../org/org-service";
|
|||||||
import { SmtpTemplates, TSmtpService } from "../smtp/smtp-service";
|
import { SmtpTemplates, TSmtpService } from "../smtp/smtp-service";
|
||||||
import { TUserDalFactory } from "../user/user-dal";
|
import { TUserDalFactory } from "../user/user-dal";
|
||||||
import { TAuthDalFactory } from "./auth-dal";
|
import { TAuthDalFactory } from "./auth-dal";
|
||||||
|
import { validateProviderAuthToken, validateSignUpAuthorization } from "./auth-fns";
|
||||||
import { TCompleteAccountInviteDTO, TCompleteAccountSignupDTO } from "./auth-signup-type";
|
import { TCompleteAccountInviteDTO, TCompleteAccountSignupDTO } from "./auth-signup-type";
|
||||||
import { AuthMethod, AuthTokenType } from "./auth-type";
|
import { AuthMethod, AuthTokenType } from "./auth-type";
|
||||||
import { validateProviderAuthToken, validateSignUpAuthorization } from "./auth-fns";
|
|
||||||
|
|
||||||
type TAuthSignupDep = {
|
type TAuthSignupDep = {
|
||||||
authDal: TAuthDalFactory;
|
authDal: TAuthDalFactory;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { BadRequestError } from "@app/lib/errors";
|
|||||||
import { TProjectPermission } from "@app/lib/types";
|
import { TProjectPermission } from "@app/lib/types";
|
||||||
|
|
||||||
import { TIntegrationAuthDalFactory } from "../integration-auth/integration-auth-dal";
|
import { TIntegrationAuthDalFactory } from "../integration-auth/integration-auth-dal";
|
||||||
|
import { TSecretQueueFactory } from "../secret/secret-queue";
|
||||||
import { TSecretFolderDalFactory } from "../secret-folder/secret-folder-dal";
|
import { TSecretFolderDalFactory } from "../secret-folder/secret-folder-dal";
|
||||||
import { TIntegrationDalFactory } from "./integration-dal";
|
import { TIntegrationDalFactory } from "./integration-dal";
|
||||||
import {
|
import {
|
||||||
@@ -16,7 +17,6 @@ import {
|
|||||||
TDeleteIntegrationDTO,
|
TDeleteIntegrationDTO,
|
||||||
TUpdateIntegrationDTO
|
TUpdateIntegrationDTO
|
||||||
} from "./integration-types";
|
} from "./integration-types";
|
||||||
import { TSecretQueueFactory } from "../secret/secret-queue";
|
|
||||||
|
|
||||||
type TIntegrationServiceFactoryDep = {
|
type TIntegrationServiceFactoryDep = {
|
||||||
integrationDal: TIntegrationDalFactory;
|
integrationDal: TIntegrationDalFactory;
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import {
|
|||||||
import { BadRequestError } from "@app/lib/errors";
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
|
|
||||||
import { TProjectDalFactory } from "../project/project-dal";
|
import { TProjectDalFactory } from "../project/project-dal";
|
||||||
|
import { TSecretFolderDalFactory } from "../secret-folder/secret-folder-dal";
|
||||||
import { TProjectEnvDalFactory } from "./project-env-dal";
|
import { TProjectEnvDalFactory } from "./project-env-dal";
|
||||||
import { TCreateEnvDTO, TDeleteEnvDTO, TUpdateEnvDTO } from "./project-env-types";
|
import { TCreateEnvDTO, TDeleteEnvDTO, TUpdateEnvDTO } from "./project-env-types";
|
||||||
import { TSecretFolderDalFactory } from "../secret-folder/secret-folder-dal";
|
|
||||||
|
|
||||||
type TProjectEnvServiceFactoryDep = {
|
type TProjectEnvServiceFactoryDep = {
|
||||||
projectEnvDal: TProjectEnvDalFactory;
|
projectEnvDal: TProjectEnvDalFactory;
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import { getConfig } from "@app/lib/config/env";
|
|||||||
import { request } from "@app/lib/config/request";
|
import { request } from "@app/lib/config/request";
|
||||||
import { decryptSymmetric, decryptSymmetric128BitHexKeyUTF8 } from "@app/lib/crypto";
|
import { decryptSymmetric, decryptSymmetric128BitHexKeyUTF8 } from "@app/lib/crypto";
|
||||||
import { BadRequestError } from "@app/lib/errors";
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
|
import { logger } from "@app/lib/logger";
|
||||||
|
|
||||||
import { TProjectEnvDalFactory } from "../project-env/project-env-dal";
|
import { TProjectEnvDalFactory } from "../project-env/project-env-dal";
|
||||||
import { TWebhookDalFactory } from "./webhook-dal";
|
import { TWebhookDalFactory } from "./webhook-dal";
|
||||||
import { logger } from "@app/lib/logger";
|
|
||||||
|
|
||||||
const WEBHOOK_TRIGGER_TIMEOUT = 15 * 1000;
|
const WEBHOOK_TRIGGER_TIMEOUT = 15 * 1000;
|
||||||
export const triggerWebhookRequest = async (
|
export const triggerWebhookRequest = async (
|
||||||
|
|||||||
Reference in New Issue
Block a user