mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 20:42:02 +00:00
feat: add credentials for kubernetes
This commit is contained in:
@@ -178,6 +178,10 @@ export const addCredentialsProvider = async (formData: FormData) => {
|
||||
client_secret: formData.get("client_secret"),
|
||||
refresh_token: formData.get("refresh_token"),
|
||||
};
|
||||
} else if (providerType === "kubernetes") {
|
||||
secret = {
|
||||
kubeconfig_content: formData.get("kubeconfig_content"),
|
||||
};
|
||||
}
|
||||
|
||||
const bodyData = {
|
||||
|
||||
@@ -16,18 +16,24 @@ import {
|
||||
AWSCredentials,
|
||||
AzureCredentials,
|
||||
GCPCredentials,
|
||||
KubernetesCredentials,
|
||||
} from "@/types";
|
||||
|
||||
import { AWScredentialsForm } from "./via-credentials/aws-credentials-form";
|
||||
import { AzureCredentialsForm } from "./via-credentials/azure-credentials-form";
|
||||
import { GCPcredentialsForm } from "./via-credentials/gcp-credentials-form";
|
||||
import { KubernetesCredentialsForm } from "./via-credentials/k8s-credentials-form";
|
||||
|
||||
type CredentialsFormSchema = z.infer<
|
||||
ReturnType<typeof addCredentialsFormSchema>
|
||||
>;
|
||||
|
||||
// Add this type intersection to include all fields
|
||||
type FormType = CredentialsFormSchema & AWSCredentials & AzureCredentials;
|
||||
type FormType = CredentialsFormSchema &
|
||||
AWSCredentials &
|
||||
AzureCredentials &
|
||||
GCPCredentials &
|
||||
KubernetesCredentials;
|
||||
|
||||
export const ViaCredentialsForm = ({
|
||||
searchParams,
|
||||
@@ -65,7 +71,11 @@ export const ViaCredentialsForm = ({
|
||||
client_secret: "",
|
||||
refresh_token: "",
|
||||
}
|
||||
: {}),
|
||||
: providerType === "kubernetes"
|
||||
? {
|
||||
kubeconfig_content: "",
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -121,6 +131,12 @@ export const ViaCredentialsForm = ({
|
||||
message: errorMessage,
|
||||
});
|
||||
break;
|
||||
case "/data/attributes/secret/kubeconfig_content":
|
||||
form.setError("kubeconfig_content", {
|
||||
type: "server",
|
||||
message: errorMessage,
|
||||
});
|
||||
break;
|
||||
case "/data/attributes/name":
|
||||
form.setError("secretName", {
|
||||
type: "server",
|
||||
@@ -164,6 +180,11 @@ export const ViaCredentialsForm = ({
|
||||
control={form.control as unknown as Control<GCPCredentials>}
|
||||
/>
|
||||
)}
|
||||
{providerType === "kubernetes" && (
|
||||
<KubernetesCredentialsForm
|
||||
control={form.control as unknown as Control<KubernetesCredentials>}
|
||||
/>
|
||||
)}
|
||||
|
||||
<span className="text-sm text-default-500">Name (Optional)</span>
|
||||
<CustomInput
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./aws-credentials-form";
|
||||
export * from "./azure-credentials-form";
|
||||
export * from "./gcp-credentials-form";
|
||||
export * from "./k8s-credentials-form";
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Control } from "react-hook-form";
|
||||
|
||||
import { CustomInput } from "@/components/ui/custom";
|
||||
import { KubernetesCredentials } from "@/types";
|
||||
|
||||
export const KubernetesCredentialsForm = ({
|
||||
control,
|
||||
}: {
|
||||
control: Control<KubernetesCredentials>;
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
<div className="text-left">
|
||||
<div className="text-2xl font-bold leading-9 text-default-foreground">
|
||||
Connect via Credentials
|
||||
</div>
|
||||
<div className="py-2 text-default-500">
|
||||
Please provide the information for your Kubernetes credentials.
|
||||
</div>
|
||||
</div>
|
||||
<CustomInput
|
||||
control={control}
|
||||
name="kubeconfig_content"
|
||||
type="text"
|
||||
label="Kubeconfig Content"
|
||||
labelPlacement="inside"
|
||||
placeholder="Enter the Kubeconfig Content"
|
||||
variant="bordered"
|
||||
isRequired
|
||||
isInvalid={!!control._formState.errors.kubeconfig_content}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
+8
-1
@@ -50,10 +50,17 @@ export type GCPCredentials = {
|
||||
providerId: string;
|
||||
};
|
||||
|
||||
export type KubernetesCredentials = {
|
||||
kubeconfig_content: string;
|
||||
secretName: string;
|
||||
providerId: string;
|
||||
};
|
||||
|
||||
export type CredentialsFormSchema =
|
||||
| AWSCredentials
|
||||
| AzureCredentials
|
||||
| GCPCredentials;
|
||||
| GCPCredentials
|
||||
| KubernetesCredentials;
|
||||
|
||||
export interface SearchParamsProps {
|
||||
[key: string]: string | string[] | undefined;
|
||||
|
||||
@@ -95,7 +95,13 @@ export const addCredentialsFormSchema = (providerType: string) =>
|
||||
client_secret: z.string().nonempty("Client Secret is required"),
|
||||
refresh_token: z.string().nonempty("Refresh Token is required"),
|
||||
}
|
||||
: {}),
|
||||
: providerType === "kubernetes"
|
||||
? {
|
||||
kubeconfig_content: z
|
||||
.string()
|
||||
.nonempty("Kubeconfig Content is required"),
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
|
||||
export const editProviderFormSchema = (currentAlias: string) =>
|
||||
|
||||
Reference in New Issue
Block a user