Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Implement getting auth
Fang-Pen Line2799b934ad3
diff --git a/backend/src/ee/services/pki-acme/pki-acme-auth-dal.ts b/backend/src/ee/services/pki-acme/pki-acme-auth-dal.tsindex d03275f9bd..880d54dc9d 100644--- a/backend/src/ee/services/pki-acme/pki-acme-auth-dal.ts+++ b/backend/src/ee/services/pki-acme/pki-acme-auth-dal.ts@@ -17,7 +17,7 @@ export const pkiAcmeAuthDALFactory = (db: TDbClient) => {.select(selectAllTableCols(TableName.PkiAcmeAuth),db.ref("id").withSchema(TableName.PkiAcmeChallenge).as("challengeId"),- db.ref("token").withSchema(TableName.PkiAcmeChallenge).as("challengeToken"),+ db.ref("type").withSchema(TableName.PkiAcmeChallenge).as("challengeType"),db.ref("status").withSchema(TableName.PkiAcmeChallenge).as("challengeStatus")).where(`${TableName.PkiAcmeAuth}.accountId`, accountId)@@ -34,9 +34,9 @@ export const pkiAcmeAuthDALFactory = (db: TDbClient) => {{key: "challengeId",label: "challenges" as const,- mapper: ({ challengeId, challengeToken, challengeStatus }) => ({+ mapper: ({ challengeId, challengeType, challengeStatus }) => ({id: challengeId,- token: challengeToken,+ type: challengeType,status: challengeStatus})}diff --git a/backend/src/ee/services/pki-acme/pki-acme-service.ts b/backend/src/ee/services/pki-acme/pki-acme-service.tsindex 97e08d7578..0658886a43 100644--- a/backend/src/ee/services/pki-acme/pki-acme-service.ts+++ b/backend/src/ee/services/pki-acme/pki-acme-service.ts@@ -49,12 +49,13 @@ import {TRawJwsPayload,TRespondToAcmeChallengeResponse} from "./pki-acme-types";+import { TPkiAcmeChallenges } from "@app/db/schemas";type TPkiAcmeServiceFactoryDep = {certificateProfileDAL: Pick<TCertificateProfileDALFactory, "findById">;acmeAccountDAL: Pick<TPkiAcmeAccountDALFactory, "findByProjectIdAndAccountId" | "findByPublicKey" | "create">;acmeOrderDAL: Pick<TPkiAcmeOrderDALFactory, "create" | "transaction" | "findByAccountAndOrderIdWithAuthorizations">;- acmeAuthDAL: Pick<TPkiAcmeAuthDALFactory, "create" | "findById">;+ acmeAuthDAL: Pick<TPkiAcmeAuthDALFactory, "create" | "findByAccountIdAndAuthIdWithChallenges">;acmeOrderAuthDAL: Pick<TPkiAcmeOrderAuthDALFactory, "insertMany">;};@@ -514,8 +515,8 @@ export const pkiAcmeServiceFactory = ({accountId: string;authzId: string;}): Promise<TAcmeResponse<TGetAcmeAuthorizationResponse>> => {- const auth = await acmeAuthDAL.findById(authzId);- if (!auth || auth.accountId !== accountId) {+ const auth = await acmeAuthDAL.findByAccountIdAndAuthIdWithChallenges(accountId, authzId);+ if (!auth) {throw new NotFoundError({ message: "ACME authorization not found" });}return {@@ -527,15 +528,16 @@ export const pkiAcmeServiceFactory = ({type: auth.identifierType,value: auth.identifierValue},- challenges: [- // TODO: fixme- {- type: "http-01",- url: buildUrl(`/api/v1/pki/acme/profiles/${profileId}/authorizations/${authzId}/challenges/http-01`),- status: "pending",+ challenges: auth.challenges.map((challenge: TPkiAcmeChallenges) => {+ return {+ type: challenge.type,+ url: buildUrl(+ `/api/v1/pki/acme/profiles/${profileId}/authorizations/${authzId}/challenges/${challenge.id}`+ ),+ status: challenge.status,token: auth.token- }- ]+ };+ })},headers: {Location: buildUrl(`/api/v1/pki/acme/profiles/${profileId}/authorizations/${authzId}`)