Unverified Commit ec26a970 authored by boojack's avatar boojack Committed by GitHub

fix: sso templates (#1753)

parent dbe8aa1d
...@@ -8,99 +8,100 @@ import { generateDialog } from "./Dialog"; ...@@ -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({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment