feat: addressed rabbit and reptile feedback

This commit is contained in:
=
2025-04-27 22:30:10 +05:30
parent 58940f31e3
commit d3d76467ac
7 changed files with 22 additions and 15 deletions

View File

@@ -1,11 +1,12 @@
import { z } from "zod";
import { GithubOrgSyncConfigsSchema } from "@app/db/schemas";
import { CharacterType, zodValidateCharacters } from "@app/lib/validator/validate-string";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
const SanitiziedGithubOrgSyncSchema = GithubOrgSyncConfigsSchema.pick({
const SanitizedGithubOrgSyncSchema = GithubOrgSyncConfigsSchema.pick({
isActive: true,
id: true,
createdAt: true,
@@ -14,6 +15,7 @@ const SanitiziedGithubOrgSyncSchema = GithubOrgSyncConfigsSchema.pick({
githubOrgName: true
});
const githubOrgNameValidator = zodValidateCharacters([CharacterType.AlphaNumeric, CharacterType.Hyphen]);
export const registerGithubOrgSyncRouter = async (server: FastifyZodProvider) => {
server.route({
url: "/",
@@ -24,13 +26,13 @@ export const registerGithubOrgSyncRouter = async (server: FastifyZodProvider) =>
onRequest: verifyAuth([AuthMode.JWT]),
schema: {
body: z.object({
githubOrgName: z.string().trim(),
githubOrgName: githubOrgNameValidator(z.string().trim(), "GitHub Org Name"),
githubOrgAccessToken: z.string().trim().max(1000).optional(),
isActive: z.boolean().default(false)
}),
response: {
200: z.object({
githubOrgSyncConfig: SanitiziedGithubOrgSyncSchema
githubOrgSyncConfig: SanitizedGithubOrgSyncSchema
})
}
},
@@ -56,14 +58,14 @@ export const registerGithubOrgSyncRouter = async (server: FastifyZodProvider) =>
schema: {
body: z
.object({
githubOrgName: z.string().trim(),
githubOrgName: githubOrgNameValidator(z.string().trim(), "GitHub Org Name"),
githubOrgAccessToken: z.string().trim().max(1000),
isActive: z.boolean().default(false)
})
.partial(),
response: {
200: z.object({
githubOrgSyncConfig: SanitiziedGithubOrgSyncSchema
githubOrgSyncConfig: SanitizedGithubOrgSyncSchema
})
}
},
@@ -89,7 +91,7 @@ export const registerGithubOrgSyncRouter = async (server: FastifyZodProvider) =>
schema: {
response: {
200: z.object({
githubOrgSyncConfig: SanitiziedGithubOrgSyncSchema
githubOrgSyncConfig: SanitizedGithubOrgSyncSchema
})
}
},
@@ -112,7 +114,7 @@ export const registerGithubOrgSyncRouter = async (server: FastifyZodProvider) =>
schema: {
response: {
200: z.object({
githubOrgSyncConfig: SanitiziedGithubOrgSyncSchema
githubOrgSyncConfig: SanitizedGithubOrgSyncSchema
})
}
},

View File

@@ -79,7 +79,7 @@ export const githubOrgSyncServiceFactory = ({
const { data } = await octokit.rest.orgs.get({
org: githubOrgName
});
if (data.login.toLowerCase() !== githubOrgName)
if (data.login.toLowerCase() !== githubOrgName.toLowerCase())
throw new BadRequestError({ message: "Invalid GitHub organisation" });
const { encryptor } = await kmsService.createCipherPairWithDataKey({
@@ -152,7 +152,7 @@ export const githubOrgSyncServiceFactory = ({
org: newData.githubOrgName
});
if (data.login.toLowerCase() !== newData.githubOrgName)
if (data.login.toLowerCase() !== newData.githubOrgName.toLowerCase())
throw new BadRequestError({ message: "Invalid GitHub organisation" });
}
@@ -280,7 +280,7 @@ export const githubOrgSyncServiceFactory = ({
const {
organization: { teams }
} = data;
const githubUserTeams = teams?.edges?.map((el) => el.node.name.toLowerCase());
const githubUserTeams = teams?.edges?.map((el) => el.node.name.toLowerCase()) || [];
const githubUserTeamSet = new Set(githubUserTeams);
const githubUserTeamOnInfisical = await groupDAL.find({ orgId, $in: { name: githubUserTeams } });
const githubUserTeamOnInfisicalGroupByName = groupBy(githubUserTeamOnInfisical, (i) => i.name);

View File

@@ -19,7 +19,7 @@ To enable and configure GitHub Organization Synchronization, follow these steps:
![config-modal](../../images/platform/external-syncs/github-org-sync-config-modal.png)
</Step>
<Step title="Enable GitHub organization sync">
Toggle ON GitHub Organization sync to active sync.
Toggle ON GitHub Organization sync to activate sync.
![toggle-on](../../images/platform/external-syncs/github-org-sync-active.png)
</Step>
<Step title="Approve the Infisical OAuth application on your organization">
@@ -33,7 +33,7 @@ To enable and configure GitHub Organization Synchronization, follow these steps:
<Info>
This action only needs to be done once and authorizes the Infisical OAuth app to read organization details, including team information.
The following users doesn't need to select organization in GitHub on login anymore.
The following users don't need to select organization in GitHub on login anymore.
</Info>
</Step>

View File

@@ -1,7 +1,7 @@
export type TGithubOrgSyncConfig = {
id: string;
orgId: string;
githubAccessToken: string;
githubOrgAccessToken?: string;
githubOrgName: string;
createdAt: string;
isActive?: boolean;

View File

@@ -110,6 +110,7 @@ export const formSchema = z.object({
"secret-scanning": generalPermissionSchema,
sso: generalPermissionSchema,
scim: generalPermissionSchema,
[OrgPermissionSubjects.GithubOrgSync]: generalPermissionSchema,
ldap: generalPermissionSchema,
billing: generalPermissionSchema,
identity: identityPermissionSchema,

View File

@@ -63,6 +63,10 @@ const SIMPLE_PERMISSION_OPTIONS = [
title: "SCIM",
formName: "scim"
},
{
title: "GitHub Organization Sync",
formName: OrgPermissionSubjects.GithubOrgSync
},
{
title: "External KMS",
formName: OrgPermissionSubjects.Kms

View File

@@ -145,7 +145,7 @@ export const GithubOrgSyncConfigModal = ({
<Button
variant="plain"
colorSchema="secondary"
onClick={() => handlePopUpToggle("deleteGithubOrgSyncConfig", false)}
onClick={() => handlePopUpToggle("githubOrgSyncConfig", false)}
>
Cancel
</Button>
@@ -163,7 +163,7 @@ export const GithubOrgSyncConfigModal = ({
<DeleteActionModal
isOpen={popUp.deleteGithubOrgSyncConfig.isOpen}
title="Are you sure want to remove GitHub organization sync?"
onChange={(isOpen) => handlePopUpToggle("githubOrgSyncConfig", isOpen)}
onChange={(isOpen) => handlePopUpToggle("deleteGithubOrgSyncConfig", isOpen)}
deleteKey="confirm"
onDeleteApproved={onDelete}
/>