fix: sso templates ()

pull/1754/head
boojack committed by GitHub
parent dbe8aa1d3a
commit ec26a9702d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,99 +8,100 @@ 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 { const templateList: IdentityProvider[] = [
identityProvider?: IdentityProvider; {
confirmCallback?: () => void; id: UNKNOWN_ID,
} name: "GitHub",
type: "OAUTH2",
const CreateIdentityProviderDialog: React.FC<Props> = (props: Props) => { identifierFilter: "",
const { t } = useTranslation(); config: {
const templateList: IdentityProvider[] = [ oauth2Config: {
{ clientId: "",
id: UNKNOWN_ID, clientSecret: "",
name: "GitHub", authUrl: "https://github.com/login/oauth/authorize",
type: "OAUTH2", tokenUrl: "https://github.com/login/oauth/access_token",
identifierFilter: "", userInfoUrl: "https://api.github.com/user",
config: { scopes: ["user"],
oauth2Config: { fieldMapping: {
clientId: "", identifier: "login",
clientSecret: "", displayName: "name",
authUrl: "https://github.com/login/oauth/authorize", email: "email",
tokenUrl: "https://github.com/login/oauth/access_token",
userInfoUrl: "https://api.github.com/user",
scopes: ["user"],
fieldMapping: {
identifier: t("setting.sso-section.identifier"),
displayName: "",
email: "",
},
}, },
}, },
}, },
{ },
id: UNKNOWN_ID, {
name: "GitLab", id: UNKNOWN_ID,
type: "OAUTH2", name: "GitLab",
identifierFilter: "", type: "OAUTH2",
config: { identifierFilter: "",
oauth2Config: { config: {
clientId: "", oauth2Config: {
clientSecret: "", clientId: "",
authUrl: "https://gitlab.com/oauth/authorize", clientSecret: "",
tokenUrl: "https://gitlab.com/oauth/token", authUrl: "https://gitlab.com/oauth/authorize",
userInfoUrl: "https://gitlab.com/oauth/userinfo", tokenUrl: "https://gitlab.com/oauth/token",
scopes: ["openid"], userInfoUrl: "https://gitlab.com/oauth/userinfo",
fieldMapping: { scopes: ["openid"],
identifier: t("setting.sso-section.identifier"), fieldMapping: {
displayName: "", identifier: "name",
email: "", displayName: "name",
}, email: "email",
}, },
}, },
}, },
{ },
id: UNKNOWN_ID, {
name: "Google", id: UNKNOWN_ID,
type: "OAUTH2", name: "Google",
identifierFilter: "", type: "OAUTH2",
config: { identifierFilter: "",
oauth2Config: { config: {
clientId: "", oauth2Config: {
clientSecret: "", clientId: "",
authUrl: "https://accounts.google.com/o/oauth2/v2/auth", clientSecret: "",
tokenUrl: "https://oauth2.googleapis.com/token", authUrl: "https://accounts.google.com/o/oauth2/v2/auth",
userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo", tokenUrl: "https://oauth2.googleapis.com/token",
scopes: ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"], userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo",
fieldMapping: { scopes: ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"],
identifier: t("setting.sso-section.identifier"), fieldMapping: {
displayName: "", identifier: "email",
email: "", displayName: "name",
}, email: "email",
}, },
}, },
}, },
{ },
id: UNKNOWN_ID, {
name: t("setting.sso-section.custom"), id: UNKNOWN_ID,
type: "OAUTH2", name: "Custom",
identifierFilter: "", type: "OAUTH2",
config: { identifierFilter: "",
oauth2Config: { config: {
clientId: "", oauth2Config: {
clientSecret: "", clientId: "",
authUrl: "", clientSecret: "",
tokenUrl: "", authUrl: "",
userInfoUrl: "", tokenUrl: "",
scopes: [], userInfoUrl: "",
fieldMapping: { scopes: [],
identifier: "", fieldMapping: {
displayName: "", identifier: "",
email: "", displayName: "",
}, email: "",
}, },
}, },
}, },
]; },
];
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({

Loading…
Cancel
Save