2022-02-13 23:39:27 +08:00
|
|
|
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
|
2021-02-13 13:30:51 +08:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
import React from "react";
|
2022-07-10 15:45:55 +08:00
|
|
|
import {Button, Card, Col, Input, InputNumber, Row, Select, Switch} from "antd";
|
2021-05-14 23:45:20 +08:00
|
|
|
import {LinkOutlined} from "@ant-design/icons";
|
2021-02-13 12:15:19 +08:00
|
|
|
import * as ProviderBackend from "./backend/ProviderBackend";
|
|
|
|
import * as Setting from "./Setting";
|
2021-02-19 23:23:59 +08:00
|
|
|
import i18next from "i18next";
|
2022-07-10 15:45:55 +08:00
|
|
|
import {authConfig} from "./auth/Auth";
|
2022-06-24 01:47:10 +08:00
|
|
|
import * as ProviderEditTestEmail from "./TestEmailWidget";
|
2022-07-10 15:45:55 +08:00
|
|
|
import copy from "copy-to-clipboard";
|
|
|
|
import {CaptchaPreview} from "./common/CaptchaPreview";
|
2022-11-21 01:17:55 +08:00
|
|
|
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
2021-02-13 12:15:19 +08:00
|
|
|
|
2022-07-10 15:45:55 +08:00
|
|
|
const {Option} = Select;
|
|
|
|
const {TextArea} = Input;
|
2021-02-14 10:20:42 +08:00
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
class ProviderEditPage extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
classes: props,
|
|
|
|
providerName: props.match.params.providerName,
|
2022-11-04 21:31:08 +08:00
|
|
|
owner: props.organizationName !== undefined ? props.organizationName : props.match.params.organizationName,
|
2021-02-13 12:15:19 +08:00
|
|
|
provider: null,
|
2022-11-21 01:17:55 +08:00
|
|
|
organizations: [],
|
2022-02-25 18:16:02 +08:00
|
|
|
mode: props.location.mode !== undefined ? props.location.mode : "edit",
|
2021-02-13 12:15:19 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-03-27 11:38:15 +08:00
|
|
|
UNSAFE_componentWillMount() {
|
2022-11-21 01:17:55 +08:00
|
|
|
this.getOrganizations();
|
2021-02-13 12:15:19 +08:00
|
|
|
this.getProvider();
|
|
|
|
}
|
|
|
|
|
|
|
|
getProvider() {
|
2022-11-04 21:31:08 +08:00
|
|
|
ProviderBackend.getProvider(this.state.owner, this.state.providerName)
|
2021-02-13 12:15:19 +08:00
|
|
|
.then((provider) => {
|
|
|
|
this.setState({
|
|
|
|
provider: provider,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-11-21 01:17:55 +08:00
|
|
|
getOrganizations() {
|
|
|
|
if (Setting.isAdminUser(this.props.account)) {
|
|
|
|
OrganizationBackend.getOrganizations("admin")
|
|
|
|
.then((res) => {
|
|
|
|
this.setState({
|
|
|
|
organizations: res.msg === undefined ? res : [],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
parseProviderField(key, value) {
|
2021-05-14 23:45:20 +08:00
|
|
|
if (["port"].includes(key)) {
|
|
|
|
value = Setting.myParseInt(value);
|
|
|
|
}
|
2021-02-13 12:15:19 +08:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateProviderField(key, value) {
|
|
|
|
value = this.parseProviderField(key, value);
|
|
|
|
|
2022-08-08 23:35:24 +08:00
|
|
|
const provider = this.state.provider;
|
2021-02-13 12:15:19 +08:00
|
|
|
provider[key] = value;
|
|
|
|
this.setState({
|
|
|
|
provider: provider,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-08-13 14:36:46 +08:00
|
|
|
getClientIdLabel() {
|
|
|
|
switch (this.state.provider.category) {
|
2022-07-10 15:45:55 +08:00
|
|
|
case "Email":
|
|
|
|
return Setting.getLabel(i18next.t("signup:Username"), i18next.t("signup:Username - Tooltip"));
|
|
|
|
case "SMS":
|
|
|
|
if (this.state.provider.type === "Volc Engine SMS") {
|
|
|
|
return Setting.getLabel(i18next.t("provider:Access key"), i18next.t("provider:Access key - Tooltip"));
|
|
|
|
} else if (this.state.provider.type === "Huawei Cloud SMS") {
|
|
|
|
return Setting.getLabel(i18next.t("provider:App key"), i18next.t("provider:App key - Tooltip"));
|
|
|
|
} else {
|
2021-08-13 14:36:46 +08:00
|
|
|
return Setting.getLabel(i18next.t("provider:Client ID"), i18next.t("provider:Client ID - Tooltip"));
|
2022-07-10 15:45:55 +08:00
|
|
|
}
|
|
|
|
case "Captcha":
|
|
|
|
if (this.state.provider.type === "Aliyun Captcha") {
|
|
|
|
return Setting.getLabel(i18next.t("provider:Access key"), i18next.t("provider:Access key - Tooltip"));
|
|
|
|
} else {
|
|
|
|
return Setting.getLabel(i18next.t("provider:Site key"), i18next.t("provider:Site key - Tooltip"));
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return Setting.getLabel(i18next.t("provider:Client ID"), i18next.t("provider:Client ID - Tooltip"));
|
2021-08-13 14:36:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getClientSecretLabel() {
|
|
|
|
switch (this.state.provider.category) {
|
2022-07-10 15:45:55 +08:00
|
|
|
case "Email":
|
|
|
|
return Setting.getLabel(i18next.t("login:Password"), i18next.t("login:Password - Tooltip"));
|
|
|
|
case "SMS":
|
|
|
|
if (this.state.provider.type === "Volc Engine SMS") {
|
|
|
|
return Setting.getLabel(i18next.t("provider:Secret access key"), i18next.t("provider:SecretAccessKey - Tooltip"));
|
|
|
|
} else if (this.state.provider.type === "Huawei Cloud SMS") {
|
|
|
|
return Setting.getLabel(i18next.t("provider:App secret"), i18next.t("provider:AppSecret - Tooltip"));
|
|
|
|
} else {
|
2021-08-13 14:36:46 +08:00
|
|
|
return Setting.getLabel(i18next.t("provider:Client secret"), i18next.t("provider:Client secret - Tooltip"));
|
2022-07-10 15:45:55 +08:00
|
|
|
}
|
|
|
|
case "Captcha":
|
|
|
|
if (this.state.provider.type === "Aliyun Captcha") {
|
|
|
|
return Setting.getLabel(i18next.t("provider:Secret access key"), i18next.t("provider:SecretAccessKey - Tooltip"));
|
|
|
|
} else {
|
|
|
|
return Setting.getLabel(i18next.t("provider:Secret key"), i18next.t("provider:Secret key - Tooltip"));
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return Setting.getLabel(i18next.t("provider:Client secret"), i18next.t("provider:Client secret - Tooltip"));
|
2021-08-13 14:36:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getAppIdRow() {
|
|
|
|
let text, tooltip;
|
|
|
|
if (this.state.provider.category === "SMS" && this.state.provider.type === "Tencent Cloud SMS") {
|
2022-01-28 23:57:54 +08:00
|
|
|
text = i18next.t("provider:App ID");
|
|
|
|
tooltip = i18next.t("provider:App ID - Tooltip");
|
|
|
|
} else if (this.state.provider.type === "WeCom" && this.state.provider.subType === "Internal") {
|
|
|
|
text = i18next.t("provider:Agent ID");
|
|
|
|
tooltip = i18next.t("provider:Agent ID - Tooltip");
|
2022-07-10 15:45:55 +08:00
|
|
|
} else if (this.state.provider.type === "Infoflow") {
|
2022-02-05 21:54:38 +08:00
|
|
|
text = i18next.t("provider:Agent ID");
|
|
|
|
tooltip = i18next.t("provider:Agent ID - Tooltip");
|
2021-08-13 14:36:46 +08:00
|
|
|
} else if (this.state.provider.category === "SMS" && this.state.provider.type === "Volc Engine SMS") {
|
2022-01-28 23:57:54 +08:00
|
|
|
text = i18next.t("provider:SMS account");
|
|
|
|
tooltip = i18next.t("provider:SMS account - Tooltip");
|
2022-03-14 20:49:03 +08:00
|
|
|
} else if (this.state.provider.category === "SMS" && this.state.provider.type === "Huawei Cloud SMS") {
|
|
|
|
text = i18next.t("provider:Channel No.");
|
|
|
|
tooltip = i18next.t("provider:Channel No. - Tooltip");
|
2022-09-04 11:21:20 +08:00
|
|
|
} else if (this.state.provider.category === "Email" && this.state.provider.type === "SUBMAIL") {
|
|
|
|
text = i18next.t("provider:App ID");
|
|
|
|
tooltip = i18next.t("provider:App ID - Tooltip");
|
2021-08-13 14:36:46 +08:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-07-10 15:45:55 +08:00
|
|
|
return <Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-01-28 23:57:54 +08:00
|
|
|
{Setting.getLabel(text, tooltip)} :
|
2021-08-13 14:36:46 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.appId} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("appId", e.target.value);
|
2021-08-13 14:36:46 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>;
|
|
|
|
}
|
|
|
|
|
2021-12-06 21:46:50 +08:00
|
|
|
loadSamlConfiguration() {
|
2022-08-08 23:35:24 +08:00
|
|
|
const parser = new DOMParser();
|
|
|
|
const xmlDoc = parser.parseFromString(this.state.provider.metadata, "text/xml");
|
|
|
|
const cert = xmlDoc.getElementsByTagName("ds:X509Certificate")[0].childNodes[0].nodeValue;
|
|
|
|
const endpoint = xmlDoc.getElementsByTagName("md:SingleSignOnService")[0].getAttribute("Location");
|
|
|
|
const issuerUrl = xmlDoc.getElementsByTagName("md:EntityDescriptor")[0].getAttribute("entityID");
|
2021-12-06 21:46:50 +08:00
|
|
|
this.updateProviderField("idP", cert);
|
|
|
|
this.updateProviderField("endpoint", endpoint);
|
|
|
|
this.updateProviderField("issuerUrl", issuerUrl);
|
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
renderProvider() {
|
|
|
|
return (
|
|
|
|
<Card size="small" title={
|
|
|
|
<div>
|
2022-02-25 18:16:02 +08:00
|
|
|
{this.state.mode === "add" ? i18next.t("provider:New Provider") : i18next.t("provider:Edit Provider")}
|
2021-12-12 18:51:12 +08:00
|
|
|
<Button onClick={() => this.submitProviderEdit(false)}>{i18next.t("general:Save")}</Button>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Button style={{marginLeft: "20px"}} type="primary" onClick={() => this.submitProviderEdit(true)}>{i18next.t("general:Save & Exit")}</Button>
|
|
|
|
{this.state.mode === "add" ? <Button style={{marginLeft: "20px"}} onClick={() => this.deleteProvider()}>{i18next.t("general:Cancel")}</Button> : null}
|
2021-02-13 12:15:19 +08:00
|
|
|
</div>
|
2022-08-06 23:43:09 +08:00
|
|
|
} style={(Setting.isMobile()) ? {margin: "5px"} : {}} type="inner">
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "10px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Name"), i18next.t("general:Name - Tooltip"))} :
|
2021-02-13 12:15:19 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.name} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("name", e.target.value);
|
2021-02-13 12:15:19 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Display name"), i18next.t("general:Display name - Tooltip"))} :
|
2021-02-13 12:15:19 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.displayName} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("displayName", e.target.value);
|
2021-02-13 12:15:19 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-11-21 01:17:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:Organization"), i18next.t("general:Organization - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Select virtual={false} style={{width: "100%"}} disabled={!Setting.isAdminUser(this.props.account)} value={this.state.provider.owner} onChange={(value => {this.updateProviderField("owner", value);})}>
|
|
|
|
{Setting.isAdminUser(this.props.account) ? <Option key={"admin"} value={"admin"}>{i18next.t("provider:admin (share)")}</Option> : null}
|
|
|
|
{
|
|
|
|
this.state.organizations.map((organization, index) => <Option key={index} value={organization.name}>{organization.name}</Option>)
|
|
|
|
}
|
|
|
|
</Select>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Category"), i18next.t("provider:Category - Tooltip"))} :
|
2021-05-14 23:45:20 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Select virtual={false} style={{width: "100%"}} value={this.state.provider.category} onChange={(value => {
|
|
|
|
this.updateProviderField("category", value);
|
2021-05-24 01:27:03 +08:00
|
|
|
if (value === "OAuth") {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("type", "GitHub");
|
2021-05-24 01:27:03 +08:00
|
|
|
} else if (value === "Email") {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("type", "Default");
|
2022-09-04 11:21:20 +08:00
|
|
|
this.updateProviderField("host", "smtp.example.com");
|
|
|
|
this.updateProviderField("port", 465);
|
2022-08-09 23:38:35 +08:00
|
|
|
this.updateProviderField("disableSsl", false);
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("title", "Casdoor Verification Code");
|
|
|
|
this.updateProviderField("content", "You have requested a verification code at Casdoor. Here is your code: %s, please enter in 5 minutes.");
|
2022-09-04 11:37:36 +08:00
|
|
|
this.updateProviderField("receiver", this.props.account.email);
|
2021-05-24 01:27:03 +08:00
|
|
|
} else if (value === "SMS") {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("type", "Aliyun SMS");
|
2021-08-06 21:33:05 +08:00
|
|
|
} else if (value === "Storage") {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("type", "Local File System");
|
|
|
|
this.updateProviderField("domain", Setting.getFullServerUrl());
|
2021-12-06 21:46:50 +08:00
|
|
|
} else if (value === "SAML") {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("type", "Aliyun IDaaS");
|
2022-08-04 19:39:25 +08:00
|
|
|
} else if (value === "Payment") {
|
|
|
|
this.updateProviderField("type", "Alipay");
|
2022-06-18 16:00:31 +08:00
|
|
|
} else if (value === "Captcha") {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("type", "Default");
|
2021-05-24 01:27:03 +08:00
|
|
|
}
|
|
|
|
})}>
|
2021-05-14 23:45:20 +08:00
|
|
|
{
|
|
|
|
[
|
2022-07-10 15:45:55 +08:00
|
|
|
{id: "OAuth", name: "OAuth"},
|
|
|
|
{id: "Email", name: "Email"},
|
|
|
|
{id: "SMS", name: "SMS"},
|
|
|
|
{id: "Storage", name: "Storage"},
|
|
|
|
{id: "SAML", name: "SAML"},
|
|
|
|
{id: "Payment", name: "Payment"},
|
|
|
|
{id: "Captcha", name: "Captcha"},
|
2021-05-14 23:45:20 +08:00
|
|
|
].map((providerCategory, index) => <Option key={index} value={providerCategory.id}>{providerCategory.name}</Option>)
|
|
|
|
}
|
|
|
|
</Select>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Type"), i18next.t("provider:Type - Tooltip"))} :
|
2021-02-13 12:15:19 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Select virtual={false} style={{width: "100%"}} value={this.state.provider.type} onChange={(value => {
|
|
|
|
this.updateProviderField("type", value);
|
2021-08-08 14:18:44 +08:00
|
|
|
if (value === "Local File System") {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("domain", Setting.getFullServerUrl());
|
2021-08-08 14:18:44 +08:00
|
|
|
}
|
2022-04-16 17:17:45 +08:00
|
|
|
if (value === "Custom") {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("customAuthUrl", "https://door.casdoor.com/login/oauth/authorize");
|
|
|
|
this.updateProviderField("customScope", "openid profile email");
|
|
|
|
this.updateProviderField("customTokenUrl", "https://door.casdoor.com/api/login/oauth/access_token");
|
|
|
|
this.updateProviderField("customUserInfoUrl", "https://door.casdoor.com/api/userinfo");
|
2022-04-16 17:17:45 +08:00
|
|
|
}
|
2021-08-08 14:18:44 +08:00
|
|
|
})}>
|
2021-02-14 10:20:42 +08:00
|
|
|
{
|
2021-12-25 10:55:10 +08:00
|
|
|
Setting.getProviderTypeOptions(this.state.provider.category).map((providerType, index) => <Option key={index} value={providerType.id}>{providerType.name}</Option>)
|
2021-02-14 10:20:42 +08:00
|
|
|
}
|
|
|
|
</Select>
|
2021-02-13 12:15:19 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2021-12-20 23:36:28 +08:00
|
|
|
{
|
2022-06-29 11:31:32 +08:00
|
|
|
this.state.provider.type !== "WeCom" && this.state.provider.type !== "Infoflow" && this.state.provider.type !== "Aliyun Captcha" ? null : (
|
2022-01-28 23:57:54 +08:00
|
|
|
<React.Fragment>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
2022-01-28 23:57:54 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Sub type"), i18next.t("provider:Sub type - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Select virtual={false} style={{width: "100%"}} value={this.state.provider.subType} onChange={value => {
|
|
|
|
this.updateProviderField("subType", value);
|
2022-01-28 23:57:54 +08:00
|
|
|
}}>
|
|
|
|
{
|
|
|
|
Setting.getProviderSubTypeOptions(this.state.provider.type).map((providerSubType, index) => <Option key={index} value={providerSubType.id}>{providerSubType.name}</Option>)
|
|
|
|
}
|
|
|
|
</Select>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-02-05 21:54:38 +08:00
|
|
|
{
|
2022-08-07 00:06:20 +08:00
|
|
|
this.state.provider.type !== "WeCom" ? null : (
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
2022-02-05 21:54:38 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Method"), i18next.t("provider:Method - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Select virtual={false} style={{width: "100%"}} value={this.state.provider.method} onChange={value => {
|
|
|
|
this.updateProviderField("method", value);
|
2022-02-05 21:54:38 +08:00
|
|
|
}}>
|
|
|
|
{
|
|
|
|
[{name: "Normal"}, {name: "Silent"}].map((method, index) => <Option key={index} value={method.name}>{method.name}</Option>)
|
|
|
|
}
|
|
|
|
</Select>
|
|
|
|
</Col>
|
|
|
|
</Row>)
|
|
|
|
}
|
2022-01-28 23:57:54 +08:00
|
|
|
</React.Fragment>
|
2021-12-20 23:36:28 +08:00
|
|
|
)
|
|
|
|
}
|
2022-04-16 17:17:45 +08:00
|
|
|
{
|
|
|
|
this.state.provider.type !== "Custom" ? null : (
|
|
|
|
<React.Fragment>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-04-16 17:17:45 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Auth URL"), i18next.t("provider:Auth URL - Tooltip"))}
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.customAuthUrl} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("customAuthUrl", e.target.value);
|
2022-04-16 17:17:45 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-04-16 17:17:45 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Scope"), i18next.t("provider:Scope - Tooltip"))}
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.customScope} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("customScope", e.target.value);
|
2022-04-16 17:17:45 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-04-16 17:17:45 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Token URL"), i18next.t("provider:Token URL - Tooltip"))}
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.customTokenUrl} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("customTokenUrl", e.target.value);
|
2022-04-16 17:17:45 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-04-16 17:17:45 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:UserInfo URL"), i18next.t("provider:UserInfo URL - Tooltip"))}
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.customUserInfoUrl} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("customUserInfoUrl", e.target.value);
|
2022-04-16 17:17:45 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("general:Favicon"), i18next.t("general:Favicon - Tooltip"))} :
|
2022-04-16 17:17:45 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 1}>
|
2022-04-16 17:17:45 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:URL"), i18next.t("general:URL - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={23} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Input prefix={<LinkOutlined />} value={this.state.provider.customLogo} onChange={e => {
|
|
|
|
this.updateProviderField("customLogo", e.target.value);
|
2022-04-16 17:17:45 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 1}>
|
2022-04-16 17:17:45 +08:00
|
|
|
{i18next.t("general:Preview")}:
|
|
|
|
</Col>
|
|
|
|
<Col span={23} >
|
|
|
|
<a target="_blank" rel="noreferrer" href={this.state.provider.customLogo}>
|
2022-07-10 15:45:55 +08:00
|
|
|
<img src={this.state.provider.customLogo} alt={this.state.provider.customLogo} height={90} style={{marginBottom: "20px"}} />
|
2022-04-16 17:17:45 +08:00
|
|
|
</a>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</React.Fragment>
|
|
|
|
)
|
|
|
|
}
|
2022-06-18 16:00:31 +08:00
|
|
|
{
|
2022-06-22 21:54:25 +08:00
|
|
|
this.state.provider.category === "Captcha" && this.state.provider.type === "Default" ? null : (
|
|
|
|
<React.Fragment>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-06-22 21:54:25 +08:00
|
|
|
{this.getClientIdLabel()}
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.clientId} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("clientId", e.target.value);
|
2022-06-22 21:54:25 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-06-22 21:54:25 +08:00
|
|
|
{this.getClientSecretLabel()}
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.clientSecret} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("clientSecret", e.target.value);
|
2022-06-22 21:54:25 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</React.Fragment>
|
|
|
|
)
|
2022-06-18 16:00:31 +08:00
|
|
|
}
|
2021-12-20 23:36:28 +08:00
|
|
|
{
|
2022-06-29 11:31:32 +08:00
|
|
|
this.state.provider.type !== "WeChat" && this.state.provider.type !== "Aliyun Captcha" ? null : (
|
2021-12-20 23:36:28 +08:00
|
|
|
<React.Fragment>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-06-29 11:31:32 +08:00
|
|
|
{this.state.provider.type === "Aliyun Captcha"
|
|
|
|
? Setting.getLabel(i18next.t("provider:Scene"), i18next.t("provider:Scene - Tooltip"))
|
|
|
|
: Setting.getLabel(i18next.t("provider:Client ID 2"), i18next.t("provider:Client ID 2 - Tooltip"))}
|
2021-12-20 23:36:28 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.clientId2} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("clientId2", e.target.value);
|
2021-12-20 23:36:28 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-06-29 11:31:32 +08:00
|
|
|
{this.state.provider.type === "Aliyun Captcha"
|
|
|
|
? Setting.getLabel(i18next.t("provider:App key"), i18next.t("provider:App key - Tooltip"))
|
|
|
|
: Setting.getLabel(i18next.t("provider:Client secret 2"), i18next.t("provider:Client secret 2 - Tooltip"))}
|
2021-12-20 23:36:28 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.clientSecret2} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("clientSecret2", e.target.value);
|
2021-12-20 23:36:28 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</React.Fragment>
|
|
|
|
)
|
|
|
|
}
|
2022-11-13 15:05:15 +08:00
|
|
|
{
|
|
|
|
this.state.provider.type !== "WeChat" ? null : (
|
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("provider:Enable QR code"), i18next.t("provider:Enable QR code - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={1} >
|
|
|
|
<Switch checked={this.state.provider.disableSsl} onChange={checked => {
|
|
|
|
this.updateProviderField("disableSsl", checked);
|
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
)
|
|
|
|
}
|
2022-02-20 15:01:48 +08:00
|
|
|
{
|
2022-08-07 00:06:20 +08:00
|
|
|
this.state.provider.type !== "Adfs" && this.state.provider.type !== "Casdoor" && this.state.provider.type !== "Okta" ? null : (
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
|
|
|
{Setting.getLabel(i18next.t("provider:Domain"), i18next.t("provider:Domain - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.domain} onChange={e => {
|
|
|
|
this.updateProviderField("domain", e.target.value);
|
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-02-20 15:01:48 +08:00
|
|
|
)
|
|
|
|
}
|
2021-07-26 11:39:49 +08:00
|
|
|
{this.state.provider.category === "Storage" ? (
|
|
|
|
<div>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
2021-12-04 16:35:33 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Endpoint"), i18next.t("provider:Region endpoint for Internet"))} :
|
2021-07-26 11:39:49 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.endpoint} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("endpoint", e.target.value);
|
2021-07-26 11:39:49 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
2021-12-04 16:35:33 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Endpoint (Intranet)"), i18next.t("provider:Region endpoint for Intranet"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.intranetEndpoint} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("intranetEndpoint", e.target.value);
|
2021-12-04 16:35:33 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
2021-07-26 11:39:49 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Bucket"), i18next.t("provider:Bucket - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.bucket} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("bucket", e.target.value);
|
2021-07-26 11:39:49 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-11-04 21:08:39 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
|
|
|
{Setting.getLabel(i18next.t("provider:Path prefix"), i18next.t("provider:The prefix path of the file - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.pathPrefix} onChange={e => {
|
|
|
|
this.updateProviderField("pathPrefix", e.target.value);
|
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
2021-07-26 11:39:49 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Domain"), i18next.t("provider:Domain - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.domain} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("domain", e.target.value);
|
2021-07-26 11:39:49 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-08-20 00:30:13 -03:00
|
|
|
{["AWS S3", "MinIO", "Tencent Cloud COS"].includes(this.state.provider.type) ? (
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={2}>
|
2021-11-28 13:35:59 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Region ID"), i18next.t("provider:Region ID - Tooltip"))} :
|
2021-07-26 11:39:49 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.regionId} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("regionId", e.target.value);
|
2021-07-26 11:39:49 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
) : null}
|
2021-05-15 13:43:21 +08:00
|
|
|
{
|
|
|
|
this.state.provider.category === "Email" ? (
|
|
|
|
<React.Fragment>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Host"), i18next.t("provider:Host - Tooltip"))} :
|
2021-05-15 13:43:21 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Input prefix={<LinkOutlined />} value={this.state.provider.host} onChange={e => {
|
|
|
|
this.updateProviderField("host", e.target.value);
|
2021-05-15 13:43:21 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Port"), i18next.t("provider:Port - Tooltip"))} :
|
2021-05-15 13:43:21 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<InputNumber value={this.state.provider.port} onChange={value => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("port", value);
|
2021-05-15 13:43:21 +08:00
|
|
|
}} />
|
2022-08-09 23:38:35 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("provider:Disable SSL"), i18next.t("provider:Disable SSL - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={1} >
|
|
|
|
<Switch checked={this.state.provider.disableSsl} onChange={checked => {
|
|
|
|
this.updateProviderField("disableSsl", checked);
|
|
|
|
}} />
|
2021-05-15 13:43:21 +08:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Email Title"), i18next.t("provider:Email Title - Tooltip"))} :
|
2021-05-24 20:21:41 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.title} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("title", e.target.value);
|
2021-05-24 20:21:41 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Email Content"), i18next.t("provider:Email Content - Tooltip"))} :
|
2021-05-24 20:21:41 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-09-04 12:15:07 +08:00
|
|
|
<TextArea autoSize={{minRows: 3, maxRows: 100}} value={this.state.provider.content} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("content", e.target.value);
|
2021-05-24 20:21:41 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-06-24 01:47:10 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Test Email"), i18next.t("provider:Test Email - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={4} >
|
2022-09-04 11:37:36 +08:00
|
|
|
<Input value={this.state.provider.receiver} placeholder = {i18next.t("user:Input your email")} onChange={e => {
|
|
|
|
this.updateProviderField("receiver", e.target.value);
|
|
|
|
}} />
|
2022-06-24 01:47:10 +08:00
|
|
|
</Col>
|
2022-09-04 11:37:36 +08:00
|
|
|
<Button style={{marginLeft: "10px", marginBottom: "5px"}} type="primary" onClick={() => ProviderEditTestEmail.connectSmtpServer(this.state.provider)} >
|
2022-06-24 01:47:10 +08:00
|
|
|
{i18next.t("provider:Test Connection")}
|
|
|
|
</Button>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Button style={{marginLeft: "10px", marginBottom: "5px"}} type="primary"
|
2022-09-04 11:37:36 +08:00
|
|
|
disabled={!Setting.isValidEmail(this.state.provider.receiver)}
|
|
|
|
onClick={() => ProviderEditTestEmail.sendTestEmail(this.state.provider, this.state.provider.receiver)} >
|
2022-06-24 01:47:10 +08:00
|
|
|
{i18next.t("provider:Send Test Email")}
|
|
|
|
</Button>
|
|
|
|
</Row>
|
2021-05-15 13:43:21 +08:00
|
|
|
</React.Fragment>
|
2021-05-23 23:38:38 +08:00
|
|
|
) : this.state.provider.category === "SMS" ? (
|
2021-05-15 13:43:21 +08:00
|
|
|
<React.Fragment>
|
2022-09-25 17:58:12 +08:00
|
|
|
{this.state.provider.type === "Twilio SMS" ?
|
|
|
|
null :
|
|
|
|
(<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
|
|
|
{Setting.getLabel(i18next.t("provider:Sign Name"), i18next.t("provider:Sign Name - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.signName} onChange={e => {
|
|
|
|
this.updateProviderField("signName", e.target.value);
|
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
)
|
|
|
|
}
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-06-30 00:58:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Template Code"), i18next.t("provider:Template Code - Tooltip"))} :
|
2021-05-15 13:43:21 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.templateCode} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("templateCode", e.target.value);
|
2021-05-15 13:43:21 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</React.Fragment>
|
2021-12-06 21:46:50 +08:00
|
|
|
) : this.state.provider.category === "SAML" ? (
|
|
|
|
<React.Fragment>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-12-15 21:38:00 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Sign request"), i18next.t("provider:Sign request - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Switch checked={this.state.provider.enableSignAuthnRequest} onChange={checked => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("enableSignAuthnRequest", checked);
|
2021-12-15 21:38:00 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-12-06 21:46:50 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Metadata"), i18next.t("provider:Metadata - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22}>
|
|
|
|
<TextArea rows={4} value={this.state.provider.metadata} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("metadata", e.target.value);
|
2021-12-06 21:46:50 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}}>
|
2022-09-25 17:58:12 +08:00
|
|
|
<Col style={{marginTop: "5px"}} span={2} />
|
2021-12-06 21:46:50 +08:00
|
|
|
<Col span={2}>
|
|
|
|
<Button type="primary" onClick={() => {
|
2022-07-10 15:45:55 +08:00
|
|
|
try {
|
|
|
|
this.loadSamlConfiguration();
|
|
|
|
Setting.showMessage("success", i18next.t("provider:Parse Metadata successfully"));
|
|
|
|
} catch (err) {
|
|
|
|
Setting.showMessage("error", i18next.t("provider:Can not parse Metadata"));
|
|
|
|
}
|
|
|
|
}}>
|
2021-12-06 21:46:50 +08:00
|
|
|
{i18next.t("provider:Parse")}
|
|
|
|
</Button>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-12-06 21:46:50 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Endpoint"), i18next.t("provider:SAML 2.0 Endpoint (HTTP)"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.endpoint} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("endpoint", e.target.value);
|
2021-12-06 21:46:50 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-07-23 09:40:51 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:IdP"), i18next.t("provider:IdP certificate"))} :
|
2021-12-06 21:46:50 +08:00
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.idP} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("idP", e.target.value);
|
2021-12-06 21:46:50 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-12-06 21:46:50 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Issuer URL"), i18next.t("provider:Issuer URL - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<Input value={this.state.provider.issuerUrl} onChange={e => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("issuerUrl", e.target.value);
|
2021-12-06 21:46:50 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-12-06 21:46:50 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:SP ACS URL"), i18next.t("provider:SP ACS URL - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={21} >
|
|
|
|
<Input value={`${authConfig.serverUrl}/api/acs`} readOnly="readonly" />
|
|
|
|
</Col>
|
|
|
|
<Col span={1}>
|
|
|
|
<Button type="primary" onClick={() => {
|
|
|
|
copy(`${authConfig.serverUrl}/api/acs`);
|
|
|
|
Setting.showMessage("success", i18next.t("provider:Link copied to clipboard successfully"));
|
|
|
|
}}>
|
|
|
|
{i18next.t("provider:Copy")}
|
|
|
|
</Button>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2021-12-06 21:46:50 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:SP Entity ID"), i18next.t("provider:SP ACS URL - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={21} >
|
|
|
|
<Input value={`${authConfig.serverUrl}/api/acs`} readOnly="readonly" />
|
|
|
|
</Col>
|
|
|
|
<Col span={1}>
|
|
|
|
<Button type="primary" onClick={() => {
|
|
|
|
copy(`${authConfig.serverUrl}/api/acs`);
|
|
|
|
Setting.showMessage("success", i18next.t("provider:Link copied to clipboard successfully"));
|
|
|
|
}}>
|
|
|
|
{i18next.t("provider:Copy")}
|
|
|
|
</Button>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</React.Fragment>
|
2021-05-15 13:43:21 +08:00
|
|
|
) : null
|
|
|
|
}
|
2021-08-13 14:36:46 +08:00
|
|
|
{this.getAppIdRow()}
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-06-22 21:54:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("provider:Provider URL"), i18next.t("provider:Provider URL - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
2022-07-10 15:45:55 +08:00
|
|
|
<Input prefix={<LinkOutlined />} value={this.state.provider.providerUrl} onChange={e => {
|
|
|
|
this.updateProviderField("providerUrl", e.target.value);
|
2022-06-22 21:54:25 +08:00
|
|
|
}} />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-06-18 16:00:31 +08:00
|
|
|
{
|
2022-06-22 21:54:25 +08:00
|
|
|
this.state.provider.category !== "Captcha" ? null : (
|
2022-07-10 15:45:55 +08:00
|
|
|
<Row style={{marginTop: "20px"}} >
|
|
|
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
2022-06-22 21:54:25 +08:00
|
|
|
{Setting.getLabel(i18next.t("general:Preview"), i18next.t("general:Preview - Tooltip"))} :
|
|
|
|
</Col>
|
|
|
|
<Col span={22} >
|
|
|
|
<CaptchaPreview
|
|
|
|
provider={this.state.provider}
|
|
|
|
providerName={this.state.providerName}
|
|
|
|
clientSecret={this.state.provider.clientSecret}
|
|
|
|
captchaType={this.state.provider.type}
|
2022-06-29 11:31:32 +08:00
|
|
|
subType={this.state.provider.subType}
|
2022-06-22 21:54:25 +08:00
|
|
|
owner={this.state.provider.owner}
|
|
|
|
clientId={this.state.provider.clientId}
|
|
|
|
name={this.state.provider.name}
|
|
|
|
providerUrl={this.state.provider.providerUrl}
|
2022-06-29 11:31:32 +08:00
|
|
|
clientId2={this.state.provider.clientId2}
|
|
|
|
clientSecret2={this.state.provider.clientSecret2}
|
2022-06-22 21:54:25 +08:00
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
)
|
2022-06-18 16:00:31 +08:00
|
|
|
}
|
2021-02-13 12:15:19 +08:00
|
|
|
</Card>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2021-02-13 12:15:19 +08:00
|
|
|
}
|
|
|
|
|
2021-12-12 18:51:12 +08:00
|
|
|
submitProviderEdit(willExist) {
|
2022-08-08 23:35:24 +08:00
|
|
|
const provider = Setting.deepCopy(this.state.provider);
|
2022-11-21 01:17:55 +08:00
|
|
|
ProviderBackend.updateProvider(this.state.owner, this.state.providerName, provider)
|
2021-02-13 12:15:19 +08:00
|
|
|
.then((res) => {
|
2021-03-28 00:48:34 +08:00
|
|
|
if (res.msg === "") {
|
2022-07-10 15:45:55 +08:00
|
|
|
Setting.showMessage("success", "Successfully saved");
|
2021-02-13 12:15:19 +08:00
|
|
|
this.setState({
|
2022-11-21 01:17:55 +08:00
|
|
|
owner: this.state.provider.owner,
|
2021-02-13 12:15:19 +08:00
|
|
|
providerName: this.state.provider.name,
|
|
|
|
});
|
2021-12-12 18:51:12 +08:00
|
|
|
|
|
|
|
if (willExist) {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.props.history.push("/providers");
|
2021-12-12 18:51:12 +08:00
|
|
|
} else {
|
2022-11-21 01:17:55 +08:00
|
|
|
this.props.history.push(`/providers/${this.state.provider.owner}/${this.state.provider.name}`);
|
2021-12-12 18:51:12 +08:00
|
|
|
}
|
2021-02-13 12:15:19 +08:00
|
|
|
} else {
|
2021-03-28 00:48:34 +08:00
|
|
|
Setting.showMessage("error", res.msg);
|
2022-07-10 15:45:55 +08:00
|
|
|
this.updateProviderField("name", this.state.providerName);
|
2021-02-13 12:15:19 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(error => {
|
2021-03-28 08:59:12 +08:00
|
|
|
Setting.showMessage("error", `Failed to connect to server: ${error}`);
|
2021-02-13 12:15:19 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-02-25 18:16:02 +08:00
|
|
|
deleteProvider() {
|
|
|
|
ProviderBackend.deleteProvider(this.state.provider)
|
|
|
|
.then(() => {
|
2022-07-10 15:45:55 +08:00
|
|
|
this.props.history.push("/providers");
|
2022-02-25 18:16:02 +08:00
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
Setting.showMessage("error", `Provider failed to delete: ${error}`);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
2021-07-23 09:46:01 +08:00
|
|
|
{
|
|
|
|
this.state.provider !== null ? this.renderProvider() : null
|
|
|
|
}
|
2022-07-10 15:45:55 +08:00
|
|
|
<div style={{marginTop: "20px", marginLeft: "40px"}}>
|
2021-12-12 18:51:12 +08:00
|
|
|
<Button size="large" onClick={() => this.submitProviderEdit(false)}>{i18next.t("general:Save")}</Button>
|
2022-07-10 15:45:55 +08:00
|
|
|
<Button style={{marginLeft: "20px"}} type="primary" size="large" onClick={() => this.submitProviderEdit(true)}>{i18next.t("general:Save & Exit")}</Button>
|
|
|
|
{this.state.mode === "add" ? <Button style={{marginLeft: "20px"}} size="large" onClick={() => this.deleteProvider()}>{i18next.t("general:Cancel")}</Button> : null}
|
2021-07-23 09:46:01 +08:00
|
|
|
</div>
|
2021-02-13 12:15:19 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ProviderEditPage;
|