mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 14:28:56 +00:00
misc: added oidc create validation in route
This commit is contained in:
@@ -242,7 +242,8 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
|
|||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT]),
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
schema: {
|
schema: {
|
||||||
body: z.object({
|
body: z
|
||||||
|
.object({
|
||||||
allowedEmailDomains: z
|
allowedEmailDomains: z
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
@@ -267,6 +268,54 @@ export const registerOidcRouter = async (server: FastifyZodProvider) => {
|
|||||||
clientSecret: z.string().trim(),
|
clientSecret: z.string().trim(),
|
||||||
isActive: z.boolean(),
|
isActive: z.boolean(),
|
||||||
orgSlug: z.string().trim()
|
orgSlug: z.string().trim()
|
||||||
|
})
|
||||||
|
.superRefine((data, ctx) => {
|
||||||
|
if (data.configurationType === OIDCConfigurationType.CUSTOM) {
|
||||||
|
if (!data.issuer) {
|
||||||
|
ctx.addIssue({
|
||||||
|
path: ["issuer"],
|
||||||
|
message: "Issuer is required",
|
||||||
|
code: z.ZodIssueCode.custom
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!data.authorizationEndpoint) {
|
||||||
|
ctx.addIssue({
|
||||||
|
path: ["authorizationEndpoint"],
|
||||||
|
message: "Authorization endpoint is required",
|
||||||
|
code: z.ZodIssueCode.custom
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!data.jwksUri) {
|
||||||
|
ctx.addIssue({
|
||||||
|
path: ["jwksUri"],
|
||||||
|
message: "JWKS URI is required",
|
||||||
|
code: z.ZodIssueCode.custom
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!data.tokenEndpoint) {
|
||||||
|
ctx.addIssue({
|
||||||
|
path: ["tokenEndpoint"],
|
||||||
|
message: "Token endpoint is required",
|
||||||
|
code: z.ZodIssueCode.custom
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!data.userinfoEndpoint) {
|
||||||
|
ctx.addIssue({
|
||||||
|
path: ["userinfoEndpoint"],
|
||||||
|
message: "Userinfo endpoint is required",
|
||||||
|
code: z.ZodIssueCode.custom
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// eslint-disable-next-line no-lonely-if
|
||||||
|
if (!data.discoveryURL) {
|
||||||
|
ctx.addIssue({
|
||||||
|
path: ["discoveryURL"],
|
||||||
|
message: "Discovery URL is required",
|
||||||
|
code: z.ZodIssueCode.custom
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: OidcConfigsSchema.pick({
|
200: OidcConfigsSchema.pick({
|
||||||
|
|||||||
Reference in New Issue
Block a user