feat: add saml metadata in application edit page (#750)

* feat: add saml metadata in application edit page

Signed-off-by: Yixiang Zhao <seriouszyx@foxmail.com>

* Update ApplicationEditPage.js

Co-authored-by: Yang Luo <hsluoyz@qq.com>
This commit is contained in:
Yixiang Zhao
2022-05-11 20:23:36 +08:00
committed by GitHub
parent 8efd964835
commit c5c3a08aa9
2 changed files with 27 additions and 0 deletions

View File

@ -35,6 +35,7 @@ require('codemirror/theme/material-darker.css');
require("codemirror/mode/htmlmixed/htmlmixed"); require("codemirror/mode/htmlmixed/htmlmixed");
const { Option } = Select; const { Option } = Select;
const { TextArea } = Input;
class ApplicationEditPage extends React.Component { class ApplicationEditPage extends React.Component {
constructor(props) { constructor(props) {
@ -48,6 +49,7 @@ class ApplicationEditPage extends React.Component {
providers: [], providers: [],
uploading: false, uploading: false,
mode: props.location.mode !== undefined ? props.location.mode : "edit", mode: props.location.mode !== undefined ? props.location.mode : "edit",
samlMetadata: null,
}; };
} }
@ -56,6 +58,7 @@ class ApplicationEditPage extends React.Component {
this.getOrganizations(); this.getOrganizations();
this.getCerts(); this.getCerts();
this.getProviders(); this.getProviders();
this.getSamlMetadata();
} }
getApplication() { getApplication() {
@ -97,6 +100,15 @@ class ApplicationEditPage extends React.Component {
}); });
} }
getSamlMetadata() {
ApplicationBackend.getSamlMetadata("admin", this.state.applicationName)
.then((res) => {
this.setState({
samlMetadata: res,
})
});
}
parseApplicationField(key, value) { parseApplicationField(key, value) {
if (["expireInHours", "refreshExpireInHours"].includes(key)) { if (["expireInHours", "refreshExpireInHours"].includes(key)) {
value = Setting.myParseInt(value); value = Setting.myParseInt(value);
@ -461,6 +473,14 @@ class ApplicationEditPage extends React.Component {
</Select> </Select>
</Col> </Col>
</Row> </Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("application:SAML metadata"), i18next.t("application:SAML metadata - Tooltip"))} :
</Col>
<Col span={22}>
<TextArea rows={8} value={this.state.samlMetadata} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} > <Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}> <Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("general:Providers"), i18next.t("general:Providers - Tooltip"))} : {Setting.getLabel(i18next.t("general:Providers"), i18next.t("general:Providers - Tooltip"))} :

View File

@ -69,3 +69,10 @@ export function deleteApplication(application) {
body: JSON.stringify(newApplication), body: JSON.stringify(newApplication),
}).then(res => res.json()); }).then(res => res.json());
} }
export function getSamlMetadata(owner, name) {
return fetch(`${Setting.ServerUrl}/api/saml/metadata?application=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include"
}).then(res => res.text());
}