Skip to content

Commit

Permalink
Feat: Default SAML/LDAP organization slug
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHougaard committed Jun 20, 2024
1 parent 6c2a5ee commit 7c94c92
Showing 1 changed file with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions frontend/src/views/admin/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const formSchema = z.object({
signUpMode: z.nativeEnum(SignUpModes),
allowedSignUpDomain: z.string().optional().nullable(),
trustSamlEmails: z.boolean(),
trustLdapEmails: z.boolean()
trustLdapEmails: z.boolean(),
defaultOrgSlug: z.string().optional().nullable()
});

type TDashboardForm = z.infer<typeof formSchema>;
Expand All @@ -60,7 +61,8 @@ export const AdminDashboardPage = () => {
signUpMode: config.allowSignUp ? SignUpModes.Anyone : SignUpModes.Disabled,
allowedSignUpDomain: config.allowedSignUpDomain,
trustSamlEmails: config.trustSamlEmails,
trustLdapEmails: config.trustLdapEmails
trustLdapEmails: config.trustLdapEmails,
defaultOrgSlug: config.defaultOrgSlug
}
});

Expand All @@ -84,9 +86,11 @@ export const AdminDashboardPage = () => {

const onFormSubmit = async (formData: TDashboardForm) => {
try {
const { signUpMode, allowedSignUpDomain, trustSamlEmails, trustLdapEmails } = formData;
const { signUpMode, allowedSignUpDomain, trustSamlEmails, trustLdapEmails, defaultOrgSlug } =
formData;

await updateServerConfig({
defaultOrgSlug,
allowSignUp: signUpMode !== SignUpModes.Disabled,
allowedSignUpDomain: signUpMode === SignUpModes.Anyone ? allowedSignUpDomain : null,
trustSamlEmails,
Expand Down Expand Up @@ -126,7 +130,7 @@ export const AdminDashboardPage = () => {
</TabList>
<TabPanel value={TabSections.Settings}>
<form
className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"
className="mb-6 space-y-8 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"
onSubmit={handleSubmit(onFormSubmit)}
>
<div className="flex flex-col justify-start">
Expand Down Expand Up @@ -161,7 +165,7 @@ export const AdminDashboardPage = () => {
/>
</div>
{signupMode === "anyone" && (
<div className="mt-8 mb-8 flex flex-col justify-start">
<div className="flex flex-col justify-start">
<div className="mb-4 text-xl font-semibold text-mineshaft-100">
Restrict signup by email domain(s)
</div>
Expand All @@ -187,7 +191,33 @@ export const AdminDashboardPage = () => {
/>
</div>
)}
<div className="mt-8 mb-8 flex flex-col justify-start">

<div className="flex flex-col justify-start">
<div className="mb-2 text-xl font-semibold text-mineshaft-100">
Default organization slug
</div>
<div className="mb-4 max-w-sm text-sm text-mineshaft-400">
Select the slug of the organization you want to set as default for SAML/LDAP
logins.
</div>
<Controller
control={control}
defaultValue=""
name="defaultOrgSlug"
render={({ field, fieldState: { error } }) => (
<FormControl
label="acme-corp"
className="w-72"
isError={Boolean(error)}
errorText={error?.message}
>
<Input {...field} value={field.value || ""} placeholder="acme-corp" />
</FormControl>
)}
/>
</div>

<div className="flex flex-col justify-start">
<div className="mb-2 text-xl font-semibold text-mineshaft-100">Trust emails</div>
<div className="mb-4 max-w-sm text-sm text-mineshaft-400">
Select if you want Infisical to trust external emails from SAML/LDAP identity
Expand Down

0 comments on commit 7c94c92

Please sign in to comment.