= [
- {
- id: "oidc",
- title: "OAuth2/OIDC",
- description: t("idpOidcDescription")
- }
- ];
-
const form = useForm({
resolver: zodResolver(createIdpFormSchema),
defaultValues: {
name: "",
- type: "oidc",
+ type: "oidc" as const,
clientId: "",
clientSecret: "",
authUrl: "",
@@ -92,25 +88,46 @@ export default function Page() {
namePath: "name",
emailPath: "email",
scopes: "openid profile email",
+ tenantId: "",
autoProvision: false
}
});
+ const watchedType = form.watch("type");
+ const templatesLocked =
+ !templatesPaid && (watchedType === "google" || watchedType === "azure");
+
async function onSubmit(data: CreateIdpFormValues) {
+ if (
+ !templatesPaid &&
+ (data.type === "google" || data.type === "azure")
+ ) {
+ return;
+ }
+
setCreateLoading(true);
try {
+ let authUrl = data.authUrl;
+ let tokenUrl = data.tokenUrl;
+
+ if (data.type === "azure" && data.tenantId) {
+ authUrl = authUrl?.replace("{{TENANT_ID}}", data.tenantId);
+ tokenUrl = tokenUrl?.replace("{{TENANT_ID}}", data.tenantId);
+ }
+
const payload = {
name: data.name,
clientId: data.clientId,
clientSecret: data.clientSecret,
- authUrl: data.authUrl,
- tokenUrl: data.tokenUrl,
+ authUrl: authUrl,
+ tokenUrl: tokenUrl,
identifierPath: data.identifierPath,
emailPath: data.emailPath,
namePath: data.namePath,
autoProvision: data.autoProvision,
- scopes: data.scopes
+ scopes: data.scopes,
+ variant: data.type
};
const res = await api.put("/idp/oidc", payload);
@@ -161,332 +178,480 @@ export default function Page() {
-
-
-
-
- {/* */}
- {/*
*/}
- {/* */}
- {/* {t("idpType")} */}
- {/* */}
- {/*
*/}
- {/* */}
- {/*
{ */}
- {/* form.setValue("type", value as "oidc"); */}
- {/* }} */}
- {/* cols={3} */}
- {/* /> */}
- {/* */}
+
+ {
+ form.setValue(
+ "autoProvision",
+ checked
+ );
+ }}
+ />
+
+
+
+
+
- {form.watch("type") === "oidc" && (
-
+
- )}
+ )}
+
+ {watchedType === "oidc" && (
+
+
+
+
+ {t("idpOidcConfigure")}
+
+
+ {t("idpOidcConfigureDescription")}
+
+
+
+
+
+ (
+
+
+ {t("idpClientId")}
+
+
+
+
+
+ {t(
+ "idpClientIdDescription"
+ )}
+
+
+
+ )}
+ />
+
+ (
+
+
+ {t(
+ "idpClientSecret"
+ )}
+
+
+
+
+
+ {t(
+ "idpClientSecretDescription"
+ )}
+
+
+
+ )}
+ />
+
+ (
+
+
+ {t("idpAuthUrl")}
+
+
+
+
+
+ {t(
+ "idpAuthUrlDescription"
+ )}
+
+
+
+ )}
+ />
+
+ (
+
+
+ {t("idpTokenUrl")}
+
+
+
+
+
+ {t(
+ "idpTokenUrlDescription"
+ )}
+
+
+
+ )}
+ />
+
+
+
+
+
+
+
+
+ {t("idpToken")}
+
+
+ {t("idpTokenDescription")}
+
+
+
+
+
+ (
+
+
+ {t(
+ "idpJmespathLabel"
+ )}
+
+
+
+
+
+ {t(
+ "idpJmespathLabelDescription"
+ )}
+
+
+
+ )}
+ />
+
+ (
+
+
+ {t(
+ "idpJmespathEmailPathOptional"
+ )}
+
+
+
+
+
+ {t(
+ "idpJmespathEmailPathOptionalDescription"
+ )}
+
+
+
+ )}
+ />
+
+ (
+
+
+ {t(
+ "idpJmespathNamePathOptional"
+ )}
+
+
+
+
+
+ {t(
+ "idpJmespathNamePathOptionalDescription"
+ )}
+
+
+
+ )}
+ />
+
+ (
+
+
+ {t(
+ "idpOidcConfigureScopes"
+ )}
+
+
+
+
+
+ {t(
+ "idpOidcConfigureScopesDescription"
+ )}
+
+
+
+ )}
+ />
+
+
+
+
+
+ )}
+
@@ -501,7 +666,7 @@ export default function Page() {
{autoProvision && (
-
-
-
- {t("roleMapping")}
-
-
- {t("roleMappingDescription")}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {roleMappingMode === "role" ? (
-
(
-
-
-
- {t("selectRoleDescription")}
-
-
-
- )}
- />
- ) : (
- (
-
-
-
-
-
- {t("roleMappingExpressionDescription")}
-
-
-
- )}
- />
- )}
-
+
)}