misc: addressed feedback

This commit is contained in:
Sheen Capadngan
2025-04-17 04:00:02 +08:00
parent fc2e5d18b7
commit 1137247e69
14 changed files with 29 additions and 29 deletions

View File

@@ -3,17 +3,17 @@ import { Knex } from "knex";
import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
if (!(await knex.schema.hasColumn(TableName.Organization, "enableBypassOrgAuth"))) {
if (!(await knex.schema.hasColumn(TableName.Organization, "bypassOrgAuthEnabled"))) {
await knex.schema.alterTable(TableName.Organization, (t) => {
t.boolean("enableBypassOrgAuth").defaultTo(false).notNullable();
t.boolean("bypassOrgAuthEnabled").defaultTo(false).notNullable();
});
}
}
export async function down(knex: Knex): Promise<void> {
if (await knex.schema.hasColumn(TableName.Organization, "enableBypassOrgAuth")) {
if (await knex.schema.hasColumn(TableName.Organization, "bypassOrgAuthEnabled")) {
await knex.schema.alterTable(TableName.Organization, (t) => {
t.dropColumn("enableBypassOrgAuth");
t.dropColumn("bypassOrgAuthEnabled");
});
}
}

View File

@@ -27,7 +27,7 @@ export const OrganizationsSchema = z.object({
shouldUseNewPrivilegeSystem: z.boolean().default(true),
privilegeUpgradeInitiatedByUsername: z.string().nullable().optional(),
privilegeUpgradeInitiatedAt: z.date().nullable().optional(),
enableBypassOrgAuth: z.boolean().default(false)
bypassOrgAuthEnabled: z.boolean().default(false)
});
export type TOrganizations = z.infer<typeof OrganizationsSchema>;

View File

@@ -54,7 +54,7 @@ export const permissionDALFactory = (db: TDbClient) => {
db.ref("slug").withSchema(TableName.OrgRoles).withSchema(TableName.OrgRoles).as("customRoleSlug"),
db.ref("permissions").withSchema(TableName.OrgRoles),
db.ref("authEnforced").withSchema(TableName.Organization).as("orgAuthEnforced"),
db.ref("enableBypassOrgAuth").withSchema(TableName.Organization).as("enableBypassOrgAuth"),
db.ref("bypassOrgAuthEnabled").withSchema(TableName.Organization).as("bypassOrgAuthEnabled"),
db.ref("groupId").withSchema("userGroups"),
db.ref("groupOrgId").withSchema("userGroups"),
db.ref("groupName").withSchema("userGroups"),
@@ -73,7 +73,7 @@ export const permissionDALFactory = (db: TDbClient) => {
OrgMembershipsSchema.extend({
permissions: z.unknown(),
orgAuthEnforced: z.boolean().optional().nullable(),
enableBypassOrgAuth: z.boolean(),
bypassOrgAuthEnabled: z.boolean(),
customRoleSlug: z.string().optional().nullable(),
shouldUseNewPrivilegeSystem: z.boolean()
}).parse(el),
@@ -678,7 +678,7 @@ export const permissionDALFactory = (db: TDbClient) => {
db.ref("key").withSchema(TableName.IdentityMetadata).as("metadataKey"),
db.ref("value").withSchema(TableName.IdentityMetadata).as("metadataValue"),
db.ref("authEnforced").withSchema(TableName.Organization).as("orgAuthEnforced"),
db.ref("enableBypassOrgAuth").withSchema(TableName.Organization).as("enableBypassOrgAuth"),
db.ref("bypassOrgAuthEnabled").withSchema(TableName.Organization).as("bypassOrgAuthEnabled"),
db.ref("role").withSchema(TableName.OrgMembership).as("orgRole"),
db.ref("orgId").withSchema(TableName.Project),
db.ref("type").withSchema(TableName.Project).as("projectType"),
@@ -702,7 +702,7 @@ export const permissionDALFactory = (db: TDbClient) => {
membershipUpdatedAt,
projectType,
shouldUseNewPrivilegeSystem,
enableBypassOrgAuth
bypassOrgAuthEnabled
}) => ({
orgId,
orgAuthEnforced,
@@ -715,7 +715,7 @@ export const permissionDALFactory = (db: TDbClient) => {
createdAt: membershipCreatedAt || groupMembershipCreatedAt,
updatedAt: membershipUpdatedAt || groupMembershipUpdatedAt,
shouldUseNewPrivilegeSystem,
enableBypassOrgAuth
bypassOrgAuthEnabled
}),
childrenMapper: [
{

View File

@@ -121,7 +121,7 @@ function isAuthMethodSaml(actorAuthMethod: ActorAuthMethod) {
function validateOrgSSO(
actorAuthMethod: ActorAuthMethod,
isOrgSsoEnforced: TOrganizations["authEnforced"],
isOrgSsoBypassEnabled: TOrganizations["enableBypassOrgAuth"],
isOrgSsoBypassEnabled: TOrganizations["bypassOrgAuthEnabled"],
orgRole: OrgMembershipRole
) {
if (actorAuthMethod === undefined) {

View File

@@ -142,7 +142,7 @@ export const permissionServiceFactory = ({
validateOrgSSO(
authMethod,
membership.orgAuthEnforced,
membership.enableBypassOrgAuth,
membership.bypassOrgAuthEnabled,
membership.role as OrgMembershipRole
);
@@ -234,7 +234,7 @@ export const permissionServiceFactory = ({
validateOrgSSO(
authMethod,
userProjectPermission.orgAuthEnforced,
userProjectPermission.enableBypassOrgAuth,
userProjectPermission.bypassOrgAuthEnabled,
userProjectPermission.orgRole
);

View File

@@ -261,7 +261,7 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
enforceMfa: z.boolean().optional(),
selectedMfaMethod: z.nativeEnum(MfaMethod).optional(),
allowSecretSharingOutsideOrganization: z.boolean().optional(),
enableBypassOrgAuth: z.boolean().optional()
bypassOrgAuthEnabled: z.boolean().optional()
}),
response: {
200: z.object({

View File

@@ -17,5 +17,5 @@ export const sanitizedOrganizationSchema = OrganizationsSchema.pick({
shouldUseNewPrivilegeSystem: true,
privilegeUpgradeInitiatedByUsername: true,
privilegeUpgradeInitiatedAt: true,
enableBypassOrgAuth: true
bypassOrgAuthEnabled: true
});

View File

@@ -350,7 +350,7 @@ export const orgServiceFactory = ({
enforceMfa,
selectedMfaMethod,
allowSecretSharingOutsideOrganization,
enableBypassOrgAuth
bypassOrgAuthEnabled
}
}: TUpdateOrgDTO) => {
const appCfg = getConfig();
@@ -431,7 +431,7 @@ export const orgServiceFactory = ({
enforceMfa,
selectedMfaMethod,
allowSecretSharingOutsideOrganization,
enableBypassOrgAuth
bypassOrgAuthEnabled
});
if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
return org;

View File

@@ -73,7 +73,7 @@ export type TUpdateOrgDTO = {
enforceMfa: boolean;
selectedMfaMethod: MfaMethod;
allowSecretSharingOutsideOrganization: boolean;
enableBypassOrgAuth: boolean;
bypassOrgAuthEnabled: boolean;
}>;
} & TOrgPermission;

View File

@@ -111,7 +111,7 @@ export const useUpdateOrg = () => {
enforceMfa,
selectedMfaMethod,
allowSecretSharingOutsideOrganization,
enableBypassOrgAuth
bypassOrgAuthEnabled
}) => {
return apiRequest.patch(`/api/v1/organization/${orgId}`, {
name,
@@ -122,7 +122,7 @@ export const useUpdateOrg = () => {
enforceMfa,
selectedMfaMethod,
allowSecretSharingOutsideOrganization,
enableBypassOrgAuth
bypassOrgAuthEnabled
});
},
onSuccess: () => {

View File

@@ -9,7 +9,7 @@ export type Organization = {
createAt: string;
updatedAt: string;
authEnforced: boolean;
enableBypassOrgAuth: boolean;
bypassOrgAuthEnabled: boolean;
orgAuthMethod: string;
scimEnabled: boolean;
slug: string;
@@ -31,7 +31,7 @@ export type UpdateOrgDTO = {
enforceMfa?: boolean;
selectedMfaMethod?: MfaMethod;
allowSecretSharingOutsideOrganization?: boolean;
enableBypassOrgAuth?: boolean;
bypassOrgAuthEnabled?: boolean;
};
export type BillingDetails = {

View File

@@ -71,7 +71,7 @@ export const SelectOrganizationPage = () => {
const handleSelectOrganization = useCallback(
async (organization: Organization) => {
const canBypassOrgAuth =
organization.enableBypassOrgAuth &&
organization.bypassOrgAuthEnabled &&
organization.userRole === OrgMembershipRole.Admin &&
isAdminLogin;

View File

@@ -65,7 +65,7 @@ export const OrgGeneralAuthSection = () => {
await mutateAsync({
orgId: currentOrg?.id,
enableBypassOrgAuth: value
bypassOrgAuthEnabled: value
});
createNotification({
@@ -129,7 +129,7 @@ export const OrgGeneralAuthSection = () => {
level.
</span>
<p className="mt-4">
In case of a lockout, admins can use the admin login portal in{" "}
In case of a lockout, admins can use the admin login portal at{" "}
<a
target="_blank"
rel="noopener noreferrer"
@@ -153,7 +153,7 @@ export const OrgGeneralAuthSection = () => {
{(isAllowed) => (
<Switch
id="allow-admin-bypass"
isChecked={currentOrg?.enableBypassOrgAuth ?? false}
isChecked={currentOrg?.bypassOrgAuthEnabled ?? false}
onCheckedChange={(value) => handleEnableBypassOrgAuthToggle(value)}
isDisabled={!isAllowed}
/>

View File

@@ -92,7 +92,7 @@ export const OrgOIDCSection = (): JSX.Element => {
await updateOrg({
orgId: currentOrg?.id,
enableBypassOrgAuth: value
bypassOrgAuthEnabled: value
});
createNotification({
@@ -212,7 +212,7 @@ export const OrgOIDCSection = (): JSX.Element => {
level.
</span>
<p className="mt-4">
In case of a lockout, admins can use the admin login portal in{" "}
In case of a lockout, admins can use the admin login portal at{" "}
<a
target="_blank"
rel="noopener noreferrer"
@@ -236,7 +236,7 @@ export const OrgOIDCSection = (): JSX.Element => {
{(isAllowed) => (
<Switch
id="allow-admin-bypass"
isChecked={currentOrg?.enableBypassOrgAuth ?? false}
isChecked={currentOrg?.bypassOrgAuthEnabled ?? false}
onCheckedChange={(value) => handleEnableBypassOrgAuthToggle(value)}
isDisabled={!isAllowed}
/>