feat: SysAdmin API Guard for Org Admins (#15867)
* adds column in schema * adds org setting to enable/disable admin api * adds guard to v1 v2 * add update query for isAdminAPIEnabled to be true for existing orgs * adds contact sales * fix typo * fix tests * fixup v2 guard * v1 fix * fix and add integration test * fixes tests --WIP * fix test --WIP * fixupgit add src/modules * WIP * fix * fix: e2e test org teams * fix: e2e test org users * review feedback * requested change * fix --------- Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Morgan <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
25 files changed
+233
-42
No files matched your search
@@ -81,6 +81,7 @@ function AdminOrgTable() {
|
||||
<ColumnTitle widthClassNames="w-auto">{t("reviewed")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("dns_configured")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("published")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">{t("admin_api")}</ColumnTitle>
|
||||
<ColumnTitle widthClassNames="w-auto">
|
||||
<span className="sr-only">{t("edit")}</span>
|
||||
</ColumnTitle>
|
||||
@@ -129,6 +130,15 @@ function AdminOrgTable() {
|
||||
)}
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<div className="space-x-2">
|
||||
{!org.organizationSettings?.isAdminAPIEnabled ? (
|
||||
<Badge variant="red">{t("disabled")}</Badge>
|
||||
) : (
|
||||
<Badge variant="green">{t("enabled")}</Badge>
|
||||
)}
|
||||
</div>
|
||||
</Cell>
|
||||
<Cell widthClassNames="w-auto">
|
||||
<div className="flex w-full justify-end">
|
||||
<DropdownActions
|
||||
@@ -185,6 +195,21 @@ function AdminOrgTable() {
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: "api",
|
||||
label: org.organizationSettings?.isAdminAPIEnabled
|
||||
? t("revoke_admin_api")
|
||||
: t("grant_admin_api"),
|
||||
onClick: () => {
|
||||
updateMutation.mutate({
|
||||
id: org.id,
|
||||
organizationSettings: {
|
||||
isAdminAPIEnabled: !org.organizationSettings?.isAdminAPIEnabled,
|
||||
},
|
||||
});
|
||||
},
|
||||
icon: "terminal" as const,
|
||||
},
|
||||
{
|
||||
id: "delete",
|
||||
label: t("delete"),
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "OrganizationSettings" ADD COLUMN "isAdminAPIEnabled" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- User written Query: Update OrganizationSettings table to mark all existing organizations to have AdminAPI Enabled to not lose functionality.
|
||||
UPDATE "OrganizationSettings" SET "isAdminAPIEnabled" = true;
|
||||
@@ -431,6 +431,7 @@ model OrganizationSettings {
|
||||
// It is used to allow super sensitive operations like 'impersonation of Org members by Org admin'
|
||||
isAdminReviewed Boolean @default(false)
|
||||
dSyncData DSyncData?
|
||||
isAdminAPIEnabled Boolean @default(false)
|
||||
}
|
||||
|
||||
enum MembershipRole {
|
||||
|
||||
@@ -1067,6 +1067,7 @@ async function main() {
|
||||
organizationSettings: {
|
||||
isOrganizationVerified: true,
|
||||
orgAutoAcceptEmail: "acme.com",
|
||||
isAdminAPIEnabled: true,
|
||||
},
|
||||
},
|
||||
members: [
|
||||
|
||||
@@ -359,6 +359,7 @@ export const orgSettingsSchema = z
|
||||
isOrganizationConfigured: z.boolean().optional(),
|
||||
isAdminReviewed: z.boolean().optional(),
|
||||
orgAutoAcceptEmail: z.string().optional(),
|
||||
isAdminAPIEnabled: z.boolean().optional(),
|
||||
})
|
||||
.nullable();
|
||||
export type userMetadataType = z.infer<typeof userMetadata>;
|
||||
|
||||
@@ -74,6 +74,9 @@ export const adminUpdateHandler = async ({ input }: AdminUpdateOptions) => {
|
||||
isAdminReviewed: organizationSettings?.isAdminReviewed,
|
||||
orgAutoAcceptEmail:
|
||||
organizationSettings?.orgAutoAcceptEmail || existingOrg.organizationSettings?.orgAutoAcceptEmail,
|
||||
isAdminAPIEnabled:
|
||||
!!organizationSettings?.isAdminAPIEnabled ??
|
||||
!!existingOrg.organizationSettings?.isAdminAPIEnabled,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user