Rename user to username

This commit is contained in:
x032205
2025-05-30 11:39:50 -04:00
parent 75e9ea9c5d
commit f4bed26781
8 changed files with 41 additions and 29 deletions
@@ -24,7 +24,7 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
approvers: z approvers: z
.discriminatedUnion("type", [ .discriminatedUnion("type", [
z.object({ type: z.literal(ApproverType.Group), id: z.string() }), z.object({ type: z.literal(ApproverType.Group), id: z.string() }),
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() }) z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), username: z.string().optional() })
]) ])
.array() .array()
.max(100, "Cannot have more than 100 approvers") .max(100, "Cannot have more than 100 approvers")
@@ -32,7 +32,7 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
bypassers: z bypassers: z
.discriminatedUnion("type", [ .discriminatedUnion("type", [
z.object({ type: z.literal(BypasserType.Group), id: z.string() }), z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() }) z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), username: z.string().optional() })
]) ])
.array() .array()
.max(100, "Cannot have more than 100 bypassers") .max(100, "Cannot have more than 100 bypassers")
@@ -153,7 +153,7 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
approvers: z approvers: z
.discriminatedUnion("type", [ .discriminatedUnion("type", [
z.object({ type: z.literal(ApproverType.Group), id: z.string() }), z.object({ type: z.literal(ApproverType.Group), id: z.string() }),
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() }) z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), username: z.string().optional() })
]) ])
.array() .array()
.min(1, { message: "At least one approver should be provided" }) .min(1, { message: "At least one approver should be provided" })
@@ -161,7 +161,7 @@ export const registerAccessApprovalPolicyRouter = async (server: FastifyZodProvi
bypassers: z bypassers: z
.discriminatedUnion("type", [ .discriminatedUnion("type", [
z.object({ type: z.literal(BypasserType.Group), id: z.string() }), z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() }) z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), username: z.string().optional() })
]) ])
.array() .array()
.max(100, "Cannot have more than 100 bypassers") .max(100, "Cannot have more than 100 bypassers")
@@ -30,7 +30,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
approvers: z approvers: z
.discriminatedUnion("type", [ .discriminatedUnion("type", [
z.object({ type: z.literal(ApproverType.Group), id: z.string() }), z.object({ type: z.literal(ApproverType.Group), id: z.string() }),
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() }) z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), username: z.string().optional() })
]) ])
.array() .array()
.min(1, { message: "At least one approver should be provided" }) .min(1, { message: "At least one approver should be provided" })
@@ -38,7 +38,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
bypassers: z bypassers: z
.discriminatedUnion("type", [ .discriminatedUnion("type", [
z.object({ type: z.literal(BypasserType.Group), id: z.string() }), z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() }) z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), username: z.string().optional() })
]) ])
.array() .array()
.max(100, "Cannot have more than 100 bypassers") .max(100, "Cannot have more than 100 bypassers")
@@ -84,7 +84,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
approvers: z approvers: z
.discriminatedUnion("type", [ .discriminatedUnion("type", [
z.object({ type: z.literal(ApproverType.Group), id: z.string() }), z.object({ type: z.literal(ApproverType.Group), id: z.string() }),
z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), name: z.string().optional() }) z.object({ type: z.literal(ApproverType.User), id: z.string().optional(), username: z.string().optional() })
]) ])
.array() .array()
.min(1, { message: "At least one approver should be provided" }) .min(1, { message: "At least one approver should be provided" })
@@ -92,7 +92,7 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
bypassers: z bypassers: z
.discriminatedUnion("type", [ .discriminatedUnion("type", [
z.object({ type: z.literal(BypasserType.Group), id: z.string() }), z.object({ type: z.literal(BypasserType.Group), id: z.string() }),
z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), name: z.string().optional() }) z.object({ type: z.literal(BypasserType.User), id: z.string().optional(), username: z.string().optional() })
]) ])
.array() .array()
.max(100, "Cannot have more than 100 bypassers") .max(100, "Cannot have more than 100 bypassers")
@@ -217,14 +217,14 @@ export const registerSecretApprovalPolicyRouter = async (server: FastifyZodProvi
.object({ .object({
id: z.string().nullable().optional(), id: z.string().nullable().optional(),
type: z.nativeEnum(ApproverType), type: z.nativeEnum(ApproverType),
name: z.string().nullable().optional() username: z.string().nullable().optional()
}) })
.array(), .array(),
bypassers: z bypassers: z
.object({ .object({
id: z.string().nullable().optional(), id: z.string().nullable().optional(),
type: z.nativeEnum(BypasserType), type: z.nativeEnum(BypasserType),
name: z.string().nullable().optional() username: z.string().nullable().optional()
}) })
.array() .array()
}) })
@@ -92,7 +92,7 @@ export const accessApprovalPolicyServiceFactory = ({
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const userApproverNames = approvers const userApproverNames = approvers
.map((approver) => (approver.type === ApproverType.User ? approver.name : undefined)) .map((approver) => (approver.type === ApproverType.User ? approver.username : undefined))
.filter(Boolean) as string[]; .filter(Boolean) as string[];
if (!groupApprovers && approvals > userApprovers.length + userApproverNames.length) if (!groupApprovers && approvals > userApprovers.length + userApproverNames.length)
@@ -171,7 +171,7 @@ export const accessApprovalPolicyServiceFactory = ({
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const userBypasserNames = bypassers const userBypasserNames = bypassers
.map((bypasser) => (bypasser.type === BypasserType.User ? bypasser.name : undefined)) .map((bypasser) => (bypasser.type === BypasserType.User ? bypasser.username : undefined))
.filter(Boolean) as string[]; .filter(Boolean) as string[];
bypasserUserIds = userBypassers; bypasserUserIds = userBypassers;
@@ -302,7 +302,7 @@ export const accessApprovalPolicyServiceFactory = ({
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const userApproverNames = approvers const userApproverNames = approvers
.map((approver) => (approver.type === ApproverType.User ? approver.name : undefined)) .map((approver) => (approver.type === ApproverType.User ? approver.username : undefined))
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const accessApprovalPolicy = await accessApprovalPolicyDAL.findById(policyId); const accessApprovalPolicy = await accessApprovalPolicyDAL.findById(policyId);
@@ -345,7 +345,7 @@ export const accessApprovalPolicyServiceFactory = ({
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const userBypasserNames = bypassers const userBypasserNames = bypassers
.map((bypasser) => (bypasser.type === BypasserType.User ? bypasser.name : undefined)) .map((bypasser) => (bypasser.type === BypasserType.User ? bypasser.username : undefined))
.filter(Boolean) as string[]; .filter(Boolean) as string[];
bypasserUserIds = userBypassers; bypasserUserIds = userBypassers;
@@ -27,8 +27,11 @@ export type TCreateAccessApprovalPolicy = {
approvals: number; approvals: number;
secretPath: string; secretPath: string;
environment: string; environment: string;
approvers: ({ type: ApproverType.Group; id: string } | { type: ApproverType.User; id?: string; name?: string })[]; approvers: ({ type: ApproverType.Group; id: string } | { type: ApproverType.User; id?: string; username?: string })[];
bypassers?: ({ type: BypasserType.Group; id: string } | { type: BypasserType.User; id?: string; name?: string })[]; bypassers?: (
| { type: BypasserType.Group; id: string }
| { type: BypasserType.User; id?: string; username?: string }
)[];
projectSlug: string; projectSlug: string;
name: string; name: string;
enforcementLevel: EnforcementLevel; enforcementLevel: EnforcementLevel;
@@ -38,8 +41,11 @@ export type TCreateAccessApprovalPolicy = {
export type TUpdateAccessApprovalPolicy = { export type TUpdateAccessApprovalPolicy = {
policyId: string; policyId: string;
approvals?: number; approvals?: number;
approvers: ({ type: ApproverType.Group; id: string } | { type: ApproverType.User; id?: string; name?: string })[]; approvers: ({ type: ApproverType.Group; id: string } | { type: ApproverType.User; id?: string; username?: string })[];
bypassers?: ({ type: BypasserType.Group; id: string } | { type: BypasserType.User; id?: string; name?: string })[]; bypassers?: (
| { type: BypasserType.Group; id: string }
| { type: BypasserType.User; id?: string; username?: string }
)[];
secretPath?: string; secretPath?: string;
name?: string; name?: string;
enforcementLevel?: EnforcementLevel; enforcementLevel?: EnforcementLevel;
@@ -15,6 +15,7 @@ import { OrgPermissionActions, OrgPermissionSubjects } from "@app/ee/services/pe
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service"; import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";
import { getConfig } from "@app/lib/config/env"; import { getConfig } from "@app/lib/config/env";
import { BadRequestError, ForbiddenRequestError, NotFoundError, OidcAuthError } from "@app/lib/errors"; import { BadRequestError, ForbiddenRequestError, NotFoundError, OidcAuthError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { OrgServiceActor } from "@app/lib/types"; import { OrgServiceActor } from "@app/lib/types";
import { ActorType, AuthMethod, AuthTokenType } from "@app/services/auth/auth-type"; import { ActorType, AuthMethod, AuthTokenType } from "@app/services/auth/auth-type";
import { TAuthTokenServiceFactory } from "@app/services/auth-token/auth-token-service"; import { TAuthTokenServiceFactory } from "@app/services/auth-token/auth-token-service";
@@ -44,7 +45,6 @@ import {
TOidcLoginDTO, TOidcLoginDTO,
TUpdateOidcCfgDTO TUpdateOidcCfgDTO
} from "./oidc-config-types"; } from "./oidc-config-types";
import { logger } from "@app/lib/logger";
type TOidcConfigServiceFactoryDep = { type TOidcConfigServiceFactoryDep = {
userDAL: Pick< userDAL: Pick<
@@ -179,7 +179,7 @@ export const secretApprovalPolicyDALFactory = (db: TDbClient) => {
label: "approvers" as const, label: "approvers" as const,
mapper: ({ approverUserId: id, approverUsername }) => ({ mapper: ({ approverUserId: id, approverUsername }) => ({
type: ApproverType.User, type: ApproverType.User,
name: approverUsername, username: approverUsername,
id id
}) })
}, },
@@ -196,7 +196,7 @@ export const secretApprovalPolicyDALFactory = (db: TDbClient) => {
label: "bypassers" as const, label: "bypassers" as const,
mapper: ({ bypasserUserId: id, bypasserUsername }) => ({ mapper: ({ bypasserUserId: id, bypasserUsername }) => ({
type: BypasserType.User, type: BypasserType.User,
name: bypasserUsername, username: bypasserUsername,
id id
}) })
}, },
@@ -80,7 +80,7 @@ export const secretApprovalPolicyServiceFactory = ({
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const userApproverNames = approvers const userApproverNames = approvers
.map((approver) => (approver.type === ApproverType.User ? approver.name : undefined)) .map((approver) => (approver.type === ApproverType.User ? approver.username : undefined))
.filter(Boolean) as string[]; .filter(Boolean) as string[];
if (!groupApprovers.length && approvals > approvers.length) if (!groupApprovers.length && approvals > approvers.length)
@@ -127,7 +127,7 @@ export const secretApprovalPolicyServiceFactory = ({
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const userBypasserNames = bypassers const userBypasserNames = bypassers
.map((bypasser) => (bypasser.type === BypasserType.User ? bypasser.name : undefined)) .map((bypasser) => (bypasser.type === BypasserType.User ? bypasser.username : undefined))
.filter(Boolean) as string[]; .filter(Boolean) as string[];
bypasserUserIds = userBypassers; bypasserUserIds = userBypassers;
@@ -252,7 +252,7 @@ export const secretApprovalPolicyServiceFactory = ({
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const userApproverNames = approvers const userApproverNames = approvers
.map((approver) => (approver.type === ApproverType.User ? approver.name : undefined)) .map((approver) => (approver.type === ApproverType.User ? approver.username : undefined))
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const secretApprovalPolicy = await secretApprovalPolicyDAL.findById(secretPolicyId); const secretApprovalPolicy = await secretApprovalPolicyDAL.findById(secretPolicyId);
@@ -294,7 +294,7 @@ export const secretApprovalPolicyServiceFactory = ({
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const userBypasserNames = bypassers const userBypasserNames = bypassers
.map((bypasser) => (bypasser.type === BypasserType.User ? bypasser.name : undefined)) .map((bypasser) => (bypasser.type === BypasserType.User ? bypasser.username : undefined))
.filter(Boolean) as string[]; .filter(Boolean) as string[];
bypasserUserIds = userBypassers; bypasserUserIds = userBypassers;
@@ -6,8 +6,11 @@ export type TCreateSapDTO = {
approvals: number; approvals: number;
secretPath?: string | null; secretPath?: string | null;
environment: string; environment: string;
approvers: ({ type: ApproverType.Group; id: string } | { type: ApproverType.User; id?: string; name?: string })[]; approvers: ({ type: ApproverType.Group; id: string } | { type: ApproverType.User; id?: string; username?: string })[];
bypassers?: ({ type: BypasserType.Group; id: string } | { type: BypasserType.User; id?: string; name?: string })[]; bypassers?: (
| { type: BypasserType.Group; id: string }
| { type: BypasserType.User; id?: string; username?: string }
)[];
projectId: string; projectId: string;
name: string; name: string;
enforcementLevel: EnforcementLevel; enforcementLevel: EnforcementLevel;
@@ -18,8 +21,11 @@ export type TUpdateSapDTO = {
secretPolicyId: string; secretPolicyId: string;
approvals?: number; approvals?: number;
secretPath?: string | null; secretPath?: string | null;
approvers: ({ type: ApproverType.Group; id: string } | { type: ApproverType.User; id?: string; name?: string })[]; approvers: ({ type: ApproverType.Group; id: string } | { type: ApproverType.User; id?: string; username?: string })[];
bypassers?: ({ type: BypasserType.Group; id: string } | { type: BypasserType.User; id?: string; name?: string })[]; bypassers?: (
| { type: BypasserType.Group; id: string }
| { type: BypasserType.User; id?: string; username?: string }
)[];
name?: string; name?: string;
enforcementLevel?: EnforcementLevel; enforcementLevel?: EnforcementLevel;
allowedSelfApprovals?: boolean; allowedSelfApprovals?: boolean;