fix: sso templates (#1753)

This commit is contained in:
boojack 2023-05-26 22:25:30 +08:00 committed by GitHub
parent dbe8aa1d3a
commit ec26a9702d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,13 +8,6 @@ import { generateDialog } from "./Dialog";
import Icon from "./Icon"; import Icon from "./Icon";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
interface Props extends DialogProps {
identityProvider?: IdentityProvider;
confirmCallback?: () => void;
}
const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
const { t } = useTranslation();
const templateList: IdentityProvider[] = [ const templateList: IdentityProvider[] = [
{ {
id: UNKNOWN_ID, id: UNKNOWN_ID,
@ -30,9 +23,9 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
userInfoUrl: "https://api.github.com/user", userInfoUrl: "https://api.github.com/user",
scopes: ["user"], scopes: ["user"],
fieldMapping: { fieldMapping: {
identifier: t("setting.sso-section.identifier"), identifier: "login",
displayName: "", displayName: "name",
email: "", email: "email",
}, },
}, },
}, },
@ -51,9 +44,9 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
userInfoUrl: "https://gitlab.com/oauth/userinfo", userInfoUrl: "https://gitlab.com/oauth/userinfo",
scopes: ["openid"], scopes: ["openid"],
fieldMapping: { fieldMapping: {
identifier: t("setting.sso-section.identifier"), identifier: "name",
displayName: "", displayName: "name",
email: "", email: "email",
}, },
}, },
}, },
@ -72,16 +65,16 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo", userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo",
scopes: ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"], scopes: ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"],
fieldMapping: { fieldMapping: {
identifier: t("setting.sso-section.identifier"), identifier: "email",
displayName: "", displayName: "name",
email: "", email: "email",
}, },
}, },
}, },
}, },
{ {
id: UNKNOWN_ID, id: UNKNOWN_ID,
name: t("setting.sso-section.custom"), name: "Custom",
type: "OAUTH2", type: "OAUTH2",
identifierFilter: "", identifierFilter: "",
config: { config: {
@ -101,6 +94,14 @@ const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
}, },
}, },
]; ];
interface Props extends DialogProps {
identityProvider?: IdentityProvider;
confirmCallback?: () => void;
}
const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => {
const { t } = useTranslation();
const identityProviderTypes = [...new Set(templateList.map((t) => t.type))]; const identityProviderTypes = [...new Set(templateList.map((t) => t.type))];
const { confirmCallback, destroy, identityProvider } = props; const { confirmCallback, destroy, identityProvider } = props;
const [basicInfo, setBasicInfo] = useState({ const [basicInfo, setBasicInfo] = useState({