mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-18 14:55:22 +00:00
✨ update policy access control
This commit is contained in:
@@ -6,6 +6,8 @@ import createHttpError from "http-errors";
|
|||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import {
|
import {
|
||||||
db,
|
db,
|
||||||
|
idp,
|
||||||
|
idpOrg,
|
||||||
orgs,
|
orgs,
|
||||||
resourcePolicies,
|
resourcePolicies,
|
||||||
rolePolicies,
|
rolePolicies,
|
||||||
@@ -107,15 +109,23 @@ export async function createResourcePolicy(
|
|||||||
|
|
||||||
const { name, sso, userIds, roleIds, skipToIdpId } = parsedBody.data;
|
const { name, sso, userIds, roleIds, skipToIdpId } = parsedBody.data;
|
||||||
|
|
||||||
const isAuthEnabeld = sso; // other conditions will follow
|
// Check if Identity provider in `skipToIdpId` exists
|
||||||
|
if (skipToIdpId) {
|
||||||
|
const [provider] = await db
|
||||||
|
.select()
|
||||||
|
.from(idp)
|
||||||
|
.innerJoin(idpOrg, eq(idpOrg.idpId, idp.idpId))
|
||||||
|
.where(and(eq(idp.idpId, skipToIdpId), eq(idpOrg.orgId, orgId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
if (!isAuthEnabeld) {
|
if (!provider) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.BAD_REQUEST,
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
"At least one authentication policy must be set: platform SSO, an authentication method, one-time password, or a rule."
|
"Identity provider not found in this organization"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const adminRole = await db
|
const adminRole = await db
|
||||||
@@ -163,7 +173,8 @@ export async function createResourcePolicy(
|
|||||||
niceId,
|
niceId,
|
||||||
orgId,
|
orgId,
|
||||||
name,
|
name,
|
||||||
sso
|
sso,
|
||||||
|
idpId: skipToIdpId
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
import { db, resourcePolicies, rolePolicies, userPolicies } from "@server/db";
|
import {
|
||||||
|
db,
|
||||||
|
idp,
|
||||||
|
resourcePolicies,
|
||||||
|
rolePolicies,
|
||||||
|
roles,
|
||||||
|
userPolicies,
|
||||||
|
users
|
||||||
|
} from "@server/db";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { OpenAPITags, registry } from "@server/openApi";
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { and, eq, type SQL } from "drizzle-orm";
|
import { and, eq, isNull, not, or, type SQL } from "drizzle-orm";
|
||||||
import type { NextFunction, Request, Response } from "express";
|
import type { NextFunction, Request, Response } from "express";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
@@ -34,26 +42,48 @@ async function query(params: z.infer<typeof getResourcePolicySchema>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const [res] = await db
|
const [res] = await db
|
||||||
.select({
|
.select()
|
||||||
policy: resourcePolicies,
|
|
||||||
userPolicies,
|
|
||||||
rolePolicies
|
|
||||||
})
|
|
||||||
.from(resourcePolicies)
|
.from(resourcePolicies)
|
||||||
.leftJoin(
|
|
||||||
userPolicies,
|
|
||||||
eq(userPolicies.resourcePolicyId, resourcePolicies.resourcePolicyId)
|
|
||||||
)
|
|
||||||
.leftJoin(
|
|
||||||
rolePolicies,
|
|
||||||
eq(rolePolicies.resourcePolicyId, resourcePolicies.resourcePolicyId)
|
|
||||||
)
|
|
||||||
.where(and(...conditions))
|
.where(and(...conditions))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
return res;
|
|
||||||
|
if (!res) return null;
|
||||||
|
|
||||||
|
const policyUsers = await db
|
||||||
|
.select({
|
||||||
|
userId: userPolicies.userId,
|
||||||
|
email: users.email,
|
||||||
|
name: users.name,
|
||||||
|
username: users.username,
|
||||||
|
type: users.type,
|
||||||
|
idpName: idp.name
|
||||||
|
})
|
||||||
|
.from(userPolicies)
|
||||||
|
.innerJoin(users, eq(userPolicies.userId, users.userId))
|
||||||
|
.leftJoin(idp, eq(idp.idpId, users.idpId))
|
||||||
|
.where(eq(userPolicies.resourcePolicyId, res.resourcePolicyId));
|
||||||
|
|
||||||
|
const policyRoles = await db
|
||||||
|
.select({
|
||||||
|
roleId: rolePolicies.roleId,
|
||||||
|
name: roles.name
|
||||||
|
})
|
||||||
|
.from(rolePolicies)
|
||||||
|
.innerJoin(
|
||||||
|
roles,
|
||||||
|
and(
|
||||||
|
eq(rolePolicies.roleId, roles.roleId),
|
||||||
|
or(isNull(roles.isAdmin), not(roles.isAdmin))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.where(eq(rolePolicies.resourcePolicyId, res.resourcePolicyId));
|
||||||
|
|
||||||
|
return { ...res, roles: policyRoles, users: policyUsers };
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GetResourcePolicyResponse = Awaited<ReturnType<typeof query>>;
|
export type GetResourcePolicyResponse = NonNullable<
|
||||||
|
Awaited<ReturnType<typeof query>>
|
||||||
|
>;
|
||||||
|
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ import HttpCode from "@server/types/HttpCode";
|
|||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import { and, eq, inArray, ne, type InferInsertModel } from "drizzle-orm";
|
import { and, eq, inArray, ne } from "drizzle-orm";
|
||||||
import { OpenAPITags, registry } from "@server/openApi";
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
|
|
||||||
const setResourcePolicyAcccessControlBodySchema = z.strictObject({
|
const setResourcePolicyAcccessControlBodySchema = z.strictObject({
|
||||||
sso: z.boolean(),
|
sso: z.boolean(),
|
||||||
userIds: z.array(z.string()),
|
userIds: z.array(z.string()),
|
||||||
roleIds: z.array(z.int().positive()),
|
roleIds: z.array(z.int().positive()),
|
||||||
skipToIdpId: z.int().positive().optional()
|
skipToIdpId: z.int().positive().optional().nullish()
|
||||||
});
|
});
|
||||||
|
|
||||||
const setResourcePolicyAccessControlParamsSchema = z.strictObject({
|
const setResourcePolicyAccessControlParamsSchema = z.strictObject({
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export default async function EditPolicyPage(props: EditPolicyPageProps) {
|
|||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<SettingsSectionTitle
|
<SettingsSectionTitle
|
||||||
title={t("resourcePolicySetting", {
|
title={t("resourcePolicySetting", {
|
||||||
policyName: policyResponse.policy.name
|
policyName: policyResponse.name
|
||||||
})}
|
})}
|
||||||
description={t("resourcePolicySettingDescription")}
|
description={t("resourcePolicySettingDescription")}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ import { useCallback, useMemo, useState, useActionState } from "react";
|
|||||||
import { UseFormReturn, useForm, useWatch } from "react-hook-form";
|
import { UseFormReturn, useForm, useWatch } from "react-hook-form";
|
||||||
import router from "next/navigation";
|
import router from "next/navigation";
|
||||||
import { useResourcePolicyContext } from "@app/providers/ResourcePolicyProvider";
|
import { useResourcePolicyContext } from "@app/providers/ResourcePolicyProvider";
|
||||||
|
import { t } from "@faker-js/faker/dist/airline-CWrCIUHH";
|
||||||
|
|
||||||
// ─── EditPolicyForm ─────────────────────────────────────────────────────────
|
// ─── EditPolicyForm ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -426,6 +427,10 @@ export function PolicyUsersRolesSection({
|
|||||||
|
|
||||||
const { policy } = useResourcePolicyContext();
|
const { policy } = useResourcePolicyContext();
|
||||||
|
|
||||||
|
const api = createApiClient(useEnvContext());
|
||||||
|
|
||||||
|
console.log({ policy });
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: zodResolver(
|
resolver: zodResolver(
|
||||||
createPolicySchema.pick({
|
createPolicySchema.pick({
|
||||||
@@ -437,7 +442,15 @@ export function PolicyUsersRolesSection({
|
|||||||
),
|
),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
sso: policy.sso,
|
sso: policy.sso,
|
||||||
skipToIdpId: policy.idpId
|
skipToIdpId: policy.idpId,
|
||||||
|
roles: policy.roles.map((role) => ({
|
||||||
|
id: role.roleId.toString(),
|
||||||
|
text: role.name
|
||||||
|
})),
|
||||||
|
users: policy.users.map((user) => ({
|
||||||
|
id: user.userId,
|
||||||
|
text: `${getUserDisplayName({ email: user.email, username: user.username })}${user.type !== UserType.Internal ? ` (${user.idpName})` : ""}`
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -453,167 +466,257 @@ export function PolicyUsersRolesSection({
|
|||||||
number | null
|
number | null
|
||||||
>(null);
|
>(null);
|
||||||
|
|
||||||
|
const [, formAction, isSubmitting] = useActionState(onSubmit, null);
|
||||||
|
|
||||||
|
async function onSubmit() {
|
||||||
|
const isValid = await form.trigger();
|
||||||
|
|
||||||
|
if (!isValid) return;
|
||||||
|
|
||||||
|
const payload = form.getValues();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await api
|
||||||
|
.put<AxiosResponse<{}>>(
|
||||||
|
`/resource-policy/${policy.resourcePolicyId}/access-control`,
|
||||||
|
{
|
||||||
|
sso: payload.sso,
|
||||||
|
userIds: payload.users.map((user) => user.id),
|
||||||
|
roleIds: payload.roles.map((role) => Number(role.id)),
|
||||||
|
skipToIdpId: payload.skipToIdpId
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.catch((e) => {
|
||||||
|
toast({
|
||||||
|
variant: "destructive",
|
||||||
|
title: t("policyErrorUpdate"),
|
||||||
|
description: formatAxiosError(
|
||||||
|
e,
|
||||||
|
t("policyErrorUpdateDescription")
|
||||||
|
)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res && res.status === 200) {
|
||||||
|
toast({
|
||||||
|
title: t("success"),
|
||||||
|
description: t("policyUpdatedSuccess")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
toast({
|
||||||
|
variant: "destructive",
|
||||||
|
title: t("policyErrorUpdate"),
|
||||||
|
description: t("policyErrorUpdateMessageDescription")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsSection>
|
<Form {...form}>
|
||||||
<SettingsSectionHeader>
|
<form action={formAction}>
|
||||||
<SettingsSectionTitle>
|
<SettingsSection>
|
||||||
{t("resourceUsersRoles")}
|
<SettingsSectionHeader>
|
||||||
</SettingsSectionTitle>
|
<SettingsSectionTitle>
|
||||||
<SettingsSectionDescription>
|
{t("resourceUsersRoles")}
|
||||||
{t("resourcePolicyUsersRolesDescription")}
|
</SettingsSectionTitle>
|
||||||
</SettingsSectionDescription>
|
<SettingsSectionDescription>
|
||||||
</SettingsSectionHeader>
|
{t("resourcePolicyUsersRolesDescription")}
|
||||||
<SettingsSectionBody>
|
</SettingsSectionDescription>
|
||||||
<SettingsSectionForm>
|
</SettingsSectionHeader>
|
||||||
<SwitchInput
|
<SettingsSectionBody>
|
||||||
id="sso-toggle"
|
<SettingsSectionForm>
|
||||||
label={t("ssoUse")}
|
<SwitchInput
|
||||||
defaultChecked={ssoEnabled}
|
id="sso-toggle"
|
||||||
onCheckedChange={(val) => {
|
label={t("ssoUse")}
|
||||||
console.log(`form.setValue("sso", ${val})`);
|
defaultChecked={ssoEnabled}
|
||||||
form.setValue("sso", val);
|
onCheckedChange={(val) => {
|
||||||
}}
|
console.log(`form.setValue("sso", ${val})`);
|
||||||
/>
|
form.setValue("sso", val);
|
||||||
|
|
||||||
{ssoEnabled && (
|
|
||||||
<>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="roles"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="flex flex-col items-start">
|
|
||||||
<FormLabel>{t("roles")}</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<TagInput
|
|
||||||
{...field}
|
|
||||||
activeTagIndex={
|
|
||||||
activeRolesTagIndex
|
|
||||||
}
|
|
||||||
setActiveTagIndex={
|
|
||||||
setActiveRolesTagIndex
|
|
||||||
}
|
|
||||||
placeholder={t(
|
|
||||||
"accessRoleSelect2"
|
|
||||||
)}
|
|
||||||
size="sm"
|
|
||||||
tags={form.getValues().roles}
|
|
||||||
setTags={(newRoles) => {
|
|
||||||
form.setValue(
|
|
||||||
"roles",
|
|
||||||
newRoles as [
|
|
||||||
Tag,
|
|
||||||
...Tag[]
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
enableAutocomplete={true}
|
|
||||||
autocompleteOptions={allRoles}
|
|
||||||
allowDuplicates={false}
|
|
||||||
restrictTagsToAutocompleteOptions={
|
|
||||||
true
|
|
||||||
}
|
|
||||||
sortTags={true}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
<FormDescription>
|
|
||||||
{t("resourceRoleDescription")}
|
|
||||||
</FormDescription>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="users"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="flex flex-col items-start">
|
|
||||||
<FormLabel>{t("users")}</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<TagInput
|
|
||||||
{...field}
|
|
||||||
activeTagIndex={
|
|
||||||
activeUsersTagIndex
|
|
||||||
}
|
|
||||||
setActiveTagIndex={
|
|
||||||
setActiveUsersTagIndex
|
|
||||||
}
|
|
||||||
placeholder={t(
|
|
||||||
"accessUserSelect"
|
|
||||||
)}
|
|
||||||
size="sm"
|
|
||||||
tags={form.getValues().users}
|
|
||||||
setTags={(newUsers) => {
|
|
||||||
form.setValue(
|
|
||||||
"users",
|
|
||||||
newUsers as [
|
|
||||||
Tag,
|
|
||||||
...Tag[]
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
enableAutocomplete={true}
|
|
||||||
autocompleteOptions={allUsers}
|
|
||||||
allowDuplicates={false}
|
|
||||||
restrictTagsToAutocompleteOptions={
|
|
||||||
true
|
|
||||||
}
|
|
||||||
sortTags={true}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{ssoEnabled && allIdps.length > 0 && (
|
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-medium">
|
|
||||||
{t("defaultIdentityProvider")}
|
|
||||||
</label>
|
|
||||||
<Select
|
|
||||||
onValueChange={(value) => {
|
|
||||||
if (value === "none") {
|
|
||||||
form.setValue("skipToIdpId", null);
|
|
||||||
} else {
|
|
||||||
const id = parseInt(value);
|
|
||||||
form.setValue("skipToIdpId", id);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
value={
|
/>
|
||||||
selectedIdpId
|
|
||||||
? selectedIdpId.toString()
|
{ssoEnabled && (
|
||||||
: "none"
|
<>
|
||||||
}
|
<FormField
|
||||||
>
|
control={form.control}
|
||||||
<SelectTrigger className="w-full mt-1">
|
name="roles"
|
||||||
<SelectValue
|
render={({ field }) => (
|
||||||
placeholder={t("selectIdpPlaceholder")}
|
<FormItem className="flex flex-col items-start">
|
||||||
|
<FormLabel>
|
||||||
|
{t("roles")}
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<TagInput
|
||||||
|
{...field}
|
||||||
|
activeTagIndex={
|
||||||
|
activeRolesTagIndex
|
||||||
|
}
|
||||||
|
setActiveTagIndex={
|
||||||
|
setActiveRolesTagIndex
|
||||||
|
}
|
||||||
|
placeholder={t(
|
||||||
|
"accessRoleSelect2"
|
||||||
|
)}
|
||||||
|
size="sm"
|
||||||
|
tags={
|
||||||
|
form.getValues()
|
||||||
|
.roles
|
||||||
|
}
|
||||||
|
setTags={(newRoles) => {
|
||||||
|
form.setValue(
|
||||||
|
"roles",
|
||||||
|
newRoles as [
|
||||||
|
Tag,
|
||||||
|
...Tag[]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
enableAutocomplete={
|
||||||
|
true
|
||||||
|
}
|
||||||
|
autocompleteOptions={
|
||||||
|
allRoles
|
||||||
|
}
|
||||||
|
allowDuplicates={false}
|
||||||
|
restrictTagsToAutocompleteOptions={
|
||||||
|
true
|
||||||
|
}
|
||||||
|
sortTags={true}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
<FormDescription>
|
||||||
|
{t(
|
||||||
|
"resourceRoleDescription"
|
||||||
|
)}
|
||||||
|
</FormDescription>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</SelectTrigger>
|
<FormField
|
||||||
<SelectContent>
|
control={form.control}
|
||||||
<SelectItem value="none">
|
name="users"
|
||||||
{t("none")}
|
render={({ field }) => (
|
||||||
</SelectItem>
|
<FormItem className="flex flex-col items-start">
|
||||||
{allIdps.map((idp) => (
|
<FormLabel>
|
||||||
<SelectItem
|
{t("users")}
|
||||||
key={idp.id}
|
</FormLabel>
|
||||||
value={idp.id.toString()}
|
<FormControl>
|
||||||
>
|
<TagInput
|
||||||
{idp.text}
|
{...field}
|
||||||
</SelectItem>
|
activeTagIndex={
|
||||||
))}
|
activeUsersTagIndex
|
||||||
</SelectContent>
|
}
|
||||||
</Select>
|
setActiveTagIndex={
|
||||||
<p className="text-sm text-muted-foreground">
|
setActiveUsersTagIndex
|
||||||
{t("defaultIdentityProviderDescription")}
|
}
|
||||||
</p>
|
placeholder={t(
|
||||||
</div>
|
"accessUserSelect"
|
||||||
)}
|
)}
|
||||||
</SettingsSectionForm>
|
size="sm"
|
||||||
</SettingsSectionBody>
|
tags={
|
||||||
</SettingsSection>
|
form.getValues()
|
||||||
|
.users
|
||||||
|
}
|
||||||
|
setTags={(newUsers) => {
|
||||||
|
form.setValue(
|
||||||
|
"users",
|
||||||
|
newUsers as [
|
||||||
|
Tag,
|
||||||
|
...Tag[]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
enableAutocomplete={
|
||||||
|
true
|
||||||
|
}
|
||||||
|
autocompleteOptions={
|
||||||
|
allUsers
|
||||||
|
}
|
||||||
|
allowDuplicates={false}
|
||||||
|
restrictTagsToAutocompleteOptions={
|
||||||
|
true
|
||||||
|
}
|
||||||
|
sortTags={true}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{ssoEnabled && allIdps.length > 0 && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<label className="text-sm font-medium">
|
||||||
|
{t("defaultIdentityProvider")}
|
||||||
|
</label>
|
||||||
|
<Select
|
||||||
|
onValueChange={(value) => {
|
||||||
|
if (value === "none") {
|
||||||
|
form.setValue(
|
||||||
|
"skipToIdpId",
|
||||||
|
null
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const id = parseInt(value);
|
||||||
|
form.setValue(
|
||||||
|
"skipToIdpId",
|
||||||
|
id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
value={
|
||||||
|
selectedIdpId
|
||||||
|
? selectedIdpId.toString()
|
||||||
|
: "none"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-full mt-1">
|
||||||
|
<SelectValue
|
||||||
|
placeholder={t(
|
||||||
|
"selectIdpPlaceholder"
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="none">
|
||||||
|
{t("none")}
|
||||||
|
</SelectItem>
|
||||||
|
{allIdps.map((idp) => (
|
||||||
|
<SelectItem
|
||||||
|
key={idp.id}
|
||||||
|
value={idp.id.toString()}
|
||||||
|
>
|
||||||
|
{idp.text}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t(
|
||||||
|
"defaultIdentityProviderDescription"
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</SettingsSectionForm>
|
||||||
|
</SettingsSectionBody>
|
||||||
|
|
||||||
|
<div className="flex py-6 justify-end">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
loading={isSubmitting}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
|
{t("saveSettings")}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</SettingsSection>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,13 +38,14 @@ export function ResourcePolicyProvider({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResourcePolicyContext value={{ ...policy, updatePolicy }}>
|
<ResourcePolicyContext value={{ policy, updatePolicy }}>
|
||||||
{children}
|
{children}
|
||||||
</ResourcePolicyContext>
|
</ResourcePolicyContext>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ResourcePolicyContextType = GetResourcePolicyResponse & {
|
export type ResourcePolicyContextType = {
|
||||||
|
policy: GetResourcePolicyResponse;
|
||||||
updatePolicy: (updatedPolicy: Partial<GetResourcePolicyResponse>) => void;
|
updatePolicy: (updatedPolicy: Partial<GetResourcePolicyResponse>) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user