mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-06 04:24:14 +00:00
support org mapping on org idp
This commit is contained in:
@@ -97,7 +97,8 @@ export default function GeneralPage() {
|
||||
emailPath: z.string().nullable().optional(),
|
||||
namePath: z.string().nullable().optional(),
|
||||
scopes: z.string().min(1, { message: t("idpScopeRequired") }),
|
||||
autoProvision: z.boolean().default(false)
|
||||
autoProvision: z.boolean().default(false),
|
||||
orgMapping: z.string().optional()
|
||||
});
|
||||
|
||||
// Google form schema (simplified)
|
||||
@@ -109,7 +110,8 @@ export default function GeneralPage() {
|
||||
.min(1, { message: t("idpClientSecretRequired") }),
|
||||
roleMapping: z.string().nullable().optional(),
|
||||
roleId: z.number().nullable().optional(),
|
||||
autoProvision: z.boolean().default(false)
|
||||
autoProvision: z.boolean().default(false),
|
||||
orgMapping: z.string().optional()
|
||||
});
|
||||
|
||||
// Azure form schema (simplified with tenant ID)
|
||||
@@ -122,7 +124,8 @@ export default function GeneralPage() {
|
||||
tenantId: z.string().min(1, { message: t("idpTenantIdRequired") }),
|
||||
roleMapping: z.string().nullable().optional(),
|
||||
roleId: z.number().nullable().optional(),
|
||||
autoProvision: z.boolean().default(false)
|
||||
autoProvision: z.boolean().default(false),
|
||||
orgMapping: z.string().optional()
|
||||
});
|
||||
|
||||
type OidcFormValues = z.infer<typeof OidcFormSchema>;
|
||||
@@ -160,7 +163,8 @@ export default function GeneralPage() {
|
||||
autoProvision: true,
|
||||
roleMapping: null,
|
||||
roleId: null,
|
||||
tenantId: ""
|
||||
tenantId: "",
|
||||
orgMapping: ""
|
||||
}
|
||||
});
|
||||
|
||||
@@ -227,7 +231,8 @@ export default function GeneralPage() {
|
||||
clientSecret: data.idpOidcConfig.clientSecret,
|
||||
autoProvision: data.idp.autoProvision,
|
||||
roleMapping: roleMapping || null,
|
||||
roleId: null
|
||||
roleId: null,
|
||||
orgMapping: data.idpOrg?.orgMapping ?? ""
|
||||
};
|
||||
|
||||
// Add variant-specific fields
|
||||
@@ -344,12 +349,14 @@ export default function GeneralPage() {
|
||||
}
|
||||
|
||||
// Build payload based on variant
|
||||
const orgMappingTrimmed = data.orgMapping?.trim() ?? "";
|
||||
let payload: any = {
|
||||
name: data.name,
|
||||
clientId: data.clientId,
|
||||
clientSecret: data.clientSecret,
|
||||
autoProvision: data.autoProvision,
|
||||
roleMapping: roleMappingExpression
|
||||
roleMapping: roleMappingExpression,
|
||||
orgMapping: orgMappingTrimmed === "" ? null : orgMappingTrimmed
|
||||
};
|
||||
|
||||
// Add variant-specific fields
|
||||
@@ -532,6 +539,10 @@ export default function GeneralPage() {
|
||||
}
|
||||
rawExpression={rawRoleExpression}
|
||||
onRawExpressionChange={setRawRoleExpression}
|
||||
orgMappingField={{
|
||||
control: form.control,
|
||||
name: "orgMapping"
|
||||
}}
|
||||
/>
|
||||
</form>
|
||||
</Form>
|
||||
|
||||
@@ -91,7 +91,8 @@ export default function Page() {
|
||||
tenantId: z.string().optional(),
|
||||
autoProvision: z.boolean().default(false),
|
||||
roleMapping: z.string().nullable().optional(),
|
||||
roleId: z.number().nullable().optional()
|
||||
roleId: z.number().nullable().optional(),
|
||||
orgMapping: z.string().optional()
|
||||
});
|
||||
|
||||
type CreateIdpFormValues = z.infer<typeof createIdpFormSchema>;
|
||||
@@ -112,7 +113,8 @@ export default function Page() {
|
||||
tenantId: "",
|
||||
autoProvision: false,
|
||||
roleMapping: null,
|
||||
roleId: null
|
||||
roleId: null,
|
||||
orgMapping: ""
|
||||
}
|
||||
});
|
||||
|
||||
@@ -177,7 +179,7 @@ export default function Page() {
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = {
|
||||
const payload: Record<string, unknown> = {
|
||||
name: data.name,
|
||||
clientId: data.clientId,
|
||||
clientSecret: data.clientSecret,
|
||||
@@ -191,6 +193,10 @@ export default function Page() {
|
||||
scopes: data.scopes,
|
||||
variant: data.type
|
||||
};
|
||||
const trimmedOrgMapping = data.orgMapping?.trim();
|
||||
if (trimmedOrgMapping) {
|
||||
payload.orgMapping = trimmedOrgMapping;
|
||||
}
|
||||
|
||||
// Use the appropriate endpoint based on provider type
|
||||
const endpoint = "oidc";
|
||||
@@ -336,6 +342,10 @@ export default function Page() {
|
||||
}
|
||||
rawExpression={rawRoleExpression}
|
||||
onRawExpressionChange={setRawRoleExpression}
|
||||
orgMappingField={{
|
||||
control: form.control,
|
||||
name: "orgMapping"
|
||||
}}
|
||||
/>
|
||||
</form>
|
||||
</Form>
|
||||
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormDescription,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
@@ -63,7 +62,7 @@ import {
|
||||
SettingsSectionForm
|
||||
} from "@app/components/Settings";
|
||||
import { useTranslations } from "next-intl";
|
||||
import RoleMappingConfigFields from "@app/components/RoleMappingConfigFields";
|
||||
import AutoProvisionConfigWidget from "@app/components/AutoProvisionConfigWidget";
|
||||
import {
|
||||
compileRoleMappingExpression,
|
||||
createMappingBuilderRule,
|
||||
@@ -499,9 +498,17 @@ export default function PoliciesPage() {
|
||||
id="policy-default-mappings-form"
|
||||
className="space-y-6"
|
||||
>
|
||||
<RoleMappingConfigFields
|
||||
fieldIdPrefix="admin-idp-default-role"
|
||||
showFreeformRoleNamesHint={true}
|
||||
<AutoProvisionConfigWidget
|
||||
showAutoProvisionSwitch={false}
|
||||
autoProvision={true}
|
||||
onAutoProvisionChange={() => {}}
|
||||
orgMappingField={{
|
||||
control: defaultMappingsForm.control,
|
||||
name: "defaultOrgMapping",
|
||||
labelKey: "defaultMappingsOrg"
|
||||
}}
|
||||
roleMappingFieldIdPrefix="admin-idp-default-role"
|
||||
showFreeformRoleNamesHint
|
||||
roleMappingMode={defaultRoleMappingMode}
|
||||
onRoleMappingModeChange={
|
||||
setDefaultRoleMappingMode
|
||||
@@ -528,27 +535,6 @@ export default function PoliciesPage() {
|
||||
setDefaultRawRoleExpression
|
||||
}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={defaultMappingsForm.control}
|
||||
name="defaultOrgMapping"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>
|
||||
{t("defaultMappingsOrg")}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
{t(
|
||||
"defaultMappingsOrgDescription"
|
||||
)}
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</form>
|
||||
</Form>
|
||||
<SettingsSectionFooter>
|
||||
@@ -687,9 +673,15 @@ export default function PoliciesPage() {
|
||||
)}
|
||||
/>
|
||||
|
||||
<RoleMappingConfigFields
|
||||
fieldIdPrefix="admin-idp-policy-role"
|
||||
showFreeformRoleNamesHint={false}
|
||||
<AutoProvisionConfigWidget
|
||||
showAutoProvisionSwitch={false}
|
||||
autoProvision={true}
|
||||
onAutoProvisionChange={() => {}}
|
||||
orgMappingField={{
|
||||
control: form.control,
|
||||
name: "orgMapping"
|
||||
}}
|
||||
roleMappingFieldIdPrefix="admin-idp-policy-role"
|
||||
roleMappingMode={policyRoleMappingMode}
|
||||
onRoleMappingModeChange={
|
||||
setPolicyRoleMappingMode
|
||||
@@ -716,27 +708,6 @@ export default function PoliciesPage() {
|
||||
setPolicyRawRoleExpression
|
||||
}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="orgMapping"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>
|
||||
{t("orgMappingPathOptional")}
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
{t(
|
||||
"defaultMappingsOrgDescription"
|
||||
)}
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</form>
|
||||
</Form>
|
||||
</CredenzaBody>
|
||||
|
||||
Reference in New Issue
Block a user