Fix account creation, remove rotation stuff for now

This commit is contained in:
Fang-Pen Lin
2025-12-05 12:07:34 -08:00
parent 5ac4e0a5bb
commit 2140956ba8
7 changed files with 136 additions and 155 deletions
@@ -3,6 +3,7 @@ import { z } from "zod";
import { PamFoldersSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { PamAccountOrderBy, PamAccountView } from "@app/ee/services/pam-account/pam-account-enums";
import { SanitizedKubernetesAccountWithResourceSchema } from "@app/ee/services/pam-resource/kubernetes/kubernetes-resource-schemas";
import { SanitizedMySQLAccountWithResourceSchema } from "@app/ee/services/pam-resource/mysql/mysql-resource-schemas";
import { PamResource } from "@app/ee/services/pam-resource/pam-resource-enums";
import { SanitizedPostgresAccountWithResourceSchema } from "@app/ee/services/pam-resource/postgres/postgres-resource-schemas";
@@ -18,7 +19,8 @@ import { AuthMode } from "@app/services/auth/auth-type";
const SanitizedAccountSchema = z.union([
SanitizedSSHAccountWithResourceSchema, // ORDER MATTERS
SanitizedPostgresAccountWithResourceSchema,
SanitizedMySQLAccountWithResourceSchema
SanitizedMySQLAccountWithResourceSchema,
SanitizedKubernetesAccountWithResourceSchema
]);
export const registerPamAccountRouter = async (server: FastifyZodProvider) => {
@@ -67,7 +67,6 @@ export const executeWithGateway = async <T>(
async (proxyPort) => {
const protocol = url.protocol === "https:" ? "https" : "http";
const baseUrl = `${protocol}://localhost:${proxyPort}`;
// const baseUrl = `http://localhost:${proxyPort}`;
return operation(baseUrl, httpsAgent);
},
{
@@ -149,7 +148,7 @@ export const kubernetesResourceFactory: TPamResourceFactory<
});
logger.info(
{ serviceAccountName: credentials.serviceAccountName, namespace: connectionDetails.namespace },
{ namespace: connectionDetails.namespace },
"[Kubernetes Resource Factory] Kubernetes service account token authentication successful"
);
} catch (error) {
@@ -30,7 +30,6 @@ export const KubernetesResourceConnectionDetailsSchema = z.object({
export const KubernetesServiceAccountTokenCredentialsSchema = z.object({
authMethod: z.literal(KubernetesAuthMethod.ServiceAccountToken),
serviceAccountName: z.string().trim().max(255),
serviceAccountToken: z.string().trim().max(10000)
});
@@ -48,8 +47,7 @@ export const SanitizedKubernetesResourceSchema = BaseKubernetesResourceSchema.ex
rotationAccountCredentials: z
.discriminatedUnion("authMethod", [
z.object({
authMethod: z.literal(KubernetesAuthMethod.ServiceAccountToken),
serviceAccountName: z.string()
authMethod: z.literal(KubernetesAuthMethod.ServiceAccountToken)
})
])
.nullable()
@@ -82,8 +80,7 @@ export const UpdateKubernetesAccountSchema = BaseUpdatePamAccountSchema.extend({
export const SanitizedKubernetesAccountWithResourceSchema = BasePamAccountSchemaWithResource.extend({
credentials: z.discriminatedUnion("authMethod", [
z.object({
authMethod: z.literal(KubernetesAuthMethod.ServiceAccountToken),
serviceAccountName: z.string()
authMethod: z.literal(KubernetesAuthMethod.ServiceAccountToken)
})
])
});