mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Fix link header overriding issue and challenge dal find method bug
This commit is contained in:
@@ -20,7 +20,7 @@ export const pkiAcmeChallengeDALFactory = (db: TDbClient) => {
|
||||
.join(TableName.PkiAcmeAuth, `${TableName.PkiAcmeChallenge}.authId`, `${TableName.PkiAcmeAuth}.id`)
|
||||
.select(
|
||||
selectAllTableCols(TableName.PkiAcmeChallenge),
|
||||
db.ref("token").withSchema(TableName.PkiAcmeChallenge).as("token")
|
||||
db.ref("token").withSchema(TableName.PkiAcmeAuth).as("token")
|
||||
)
|
||||
.where(`${TableName.PkiAcmeChallenge}.id`, challengeId)
|
||||
.where(`${TableName.PkiAcmeChallenge}.authId`, authId)
|
||||
|
||||
@@ -158,6 +158,8 @@ export const GetAcmeAuthorizationResponseSchema = z.object({
|
||||
)
|
||||
});
|
||||
|
||||
export const RespondToAcmeChallengeBodySchema = z.object({});
|
||||
|
||||
export const RespondToAcmeChallengeResponseSchema = z.object({
|
||||
type: z.enum(Object.values(AcmeChallengeType) as [string, ...string[]]),
|
||||
url: z.string(),
|
||||
|
||||
@@ -300,10 +300,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
contact: existingAccount.emails,
|
||||
orders: buildUrl(profile.id, `/accounts/${existingAccount.id}/orders`)
|
||||
},
|
||||
headers: [
|
||||
["Location", buildUrl(profile.id, `/accounts/${existingAccount.id}`)],
|
||||
["Link", `<${buildUrl(profile.id, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profile.id, `/accounts/${existingAccount.id}`),
|
||||
Link: `<${buildUrl(profile.id, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -322,10 +322,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
contact: newAccount.emails,
|
||||
orders: buildUrl(profile.id, `/accounts/${newAccount.id}/orders`)
|
||||
},
|
||||
headers: [
|
||||
["Location", buildUrl(profile.id, `/accounts/${newAccount.id}`)],
|
||||
["Link", `<${buildUrl(profile.id, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profile.id, `/accounts/${newAccount.id}`),
|
||||
Link: `<${buildUrl(profile.id, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -345,10 +345,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
body: {
|
||||
status: "deactivated"
|
||||
},
|
||||
headers: [
|
||||
["Location", buildUrl(profileId, `/accounts/${accountId}`)],
|
||||
["Link", `<${buildUrl(profileId, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profileId, `/accounts/${accountId}`),
|
||||
Link: `<${buildUrl(profileId, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -432,10 +432,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
profileId,
|
||||
order
|
||||
}),
|
||||
headers: [
|
||||
["Location", buildUrl(profileId, `/orders/${order.id}`)],
|
||||
["Link", `<${buildUrl(profileId, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profileId, `/orders/${order.id}`),
|
||||
Link: `<${buildUrl(profileId, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -455,10 +455,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
return {
|
||||
status: 200,
|
||||
body: buildAcmeOrderResource({ profileId, order }),
|
||||
headers: [
|
||||
["Location", buildUrl(profileId, `/orders/${orderId}`)],
|
||||
["Link", `<${buildUrl(profileId, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profileId, `/orders/${orderId}`),
|
||||
Link: `<${buildUrl(profileId, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -482,10 +482,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
return {
|
||||
status: 200,
|
||||
body: buildAcmeOrderResource({ profileId, order }),
|
||||
headers: [
|
||||
["Location", buildUrl(profileId, `/orders/${orderId}`)],
|
||||
["Link", `<${buildUrl(profileId, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profileId, `/orders/${orderId}`),
|
||||
Link: `<${buildUrl(profileId, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -507,10 +507,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
return {
|
||||
status: 200,
|
||||
body: "FIXME-certificate-pem",
|
||||
headers: [
|
||||
["Location", buildUrl(profileId, `/orders/${orderId}/certificate`)],
|
||||
["Link", `<${buildUrl(profileId, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profileId, `/orders/${orderId}/certificate`),
|
||||
Link: `<${buildUrl(profileId, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -528,10 +528,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
body: {
|
||||
orders: []
|
||||
},
|
||||
headers: [
|
||||
["Location", buildUrl(profileId, `/accounts/${accountId}/orders`)],
|
||||
["Link", `<${buildUrl(profileId, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profileId, `/accounts/${accountId}/orders`),
|
||||
Link: `<${buildUrl(profileId, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -569,10 +569,10 @@ export const pkiAcmeServiceFactory = ({
|
||||
};
|
||||
})
|
||||
},
|
||||
headers: [
|
||||
["Location", buildUrl(profileId, `/authorizations/${authzId}`)],
|
||||
["Link", `<${buildUrl(profileId, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profileId, `/authorizations/${authzId}`),
|
||||
Link: `<${buildUrl(profileId, "/directory")}>;rel="index"`
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -600,11 +600,13 @@ export const pkiAcmeServiceFactory = ({
|
||||
status: challenge.status,
|
||||
token: challenge.token
|
||||
},
|
||||
headers: [
|
||||
["Location", buildUrl(profileId, `/authorizations/${authzId}/challenges/http-01`)],
|
||||
["Link", `<${buildUrl(profileId, `/authorizations/${authzId}`)}>;rel="up"`],
|
||||
["Link", `<${buildUrl(profileId, "/directory")}>;rel="index"`]
|
||||
]
|
||||
headers: {
|
||||
Location: buildUrl(profileId, `/authorizations/${authzId}/challenges/${challengeId}`),
|
||||
Link: [
|
||||
`<${buildUrl(profileId, `/authorizations/${authzId}`)}>;rel="up"`,
|
||||
`<${buildUrl(profileId, "/directory")}>;rel="index"`
|
||||
]
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export type TAuthenciatedJwsPayload<T> = TJwsPayload<T> & {
|
||||
};
|
||||
export type TAcmeResponse<TPayload> = {
|
||||
status: number;
|
||||
headers: [string, string][];
|
||||
headers: Record<string, string | string[]>;
|
||||
body: TPayload;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user