fix(系统设置): 认证设置表单参数校验
This commit is contained in:
parent
5a6299fa4f
commit
ad5bccccbc
|
@ -82,16 +82,16 @@
|
||||||
<div class="node-line" v-if="form.type === 'CAS'">
|
<div class="node-line" v-if="form.type === 'CAS'">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="CAS URL" :rules="requiredRules">
|
<el-form-item label="CAS URL" :rules="requiredRules" prop="configuration.casUrl">
|
||||||
<el-input v-model="form.configuration.casUrl" placeholder="eg: http://<casurl>"/>
|
<el-input v-model="form.configuration.casUrl" placeholder="eg: http://<casurl>"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="Login URL" :rules="requiredRules">
|
<el-form-item label="Login URL" :rules="requiredRules" prop="configuration.loginUrl">
|
||||||
<el-input v-model="form.configuration.loginUrl" placeholder="eg: http://<casurl>/login"/>
|
<el-input v-model="form.configuration.loginUrl" placeholder="eg: http://<casurl>/login"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="Validate URL" :rules="requiredRules">
|
<el-form-item label="Validate URL" :rules="requiredRules" prop="configuration.validateUrl">
|
||||||
<el-input v-model="form.configuration.validateUrl" placeholder="eg: http://<casurl>/serviceValidate"/>
|
<el-input v-model="form.configuration.validateUrl" placeholder="eg: http://<casurl>/serviceValidate"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :rules="requiredRules">
|
<el-form-item :rules="requiredRules" prop="configuration.redirectUrl">
|
||||||
<template v-slot:label>
|
<template v-slot:label>
|
||||||
Redirect URL
|
Redirect URL
|
||||||
<el-tooltip content="Logout redirect URL: http://<metersphere-endpoint>/sso/callback/cas/logout"
|
<el-tooltip content="Logout redirect URL: http://<metersphere-endpoint>/sso/callback/cas/logout"
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Auth Endpoint"
|
<el-form-item label="Auth Endpoint"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules" prop="configuration.authUrl">
|
||||||
<el-input v-model="form.configuration.authUrl"
|
<el-input v-model="form.configuration.authUrl"
|
||||||
placeholder="eg: http://<keycloak>/auth/realms/<metersphere>/protocol/openid-connect/auth"/>
|
placeholder="eg: http://<keycloak>/auth/realms/<metersphere>/protocol/openid-connect/auth"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Token Endpoint"
|
<el-form-item label="Token Endpoint"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules" prop="configuration.tokenUrl">
|
||||||
<el-input v-model="form.configuration.tokenUrl"
|
<el-input v-model="form.configuration.tokenUrl"
|
||||||
placeholder="eg: http://<keycloak>/auth/realms/<metersphere>/protocol/openid-connect/token"/>
|
placeholder="eg: http://<keycloak>/auth/realms/<metersphere>/protocol/openid-connect/token"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Userinfo Endpoint"
|
<el-form-item label="Userinfo Endpoint"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules" prop="configuration.userInfoUrl">
|
||||||
<el-input v-model="form.configuration.userInfoUrl"
|
<el-input v-model="form.configuration.userInfoUrl"
|
||||||
placeholder="eg: http://<keycloak>/auth/realms/<metersphere>/protocol/openid-connect/userinfo"/>
|
placeholder="eg: http://<keycloak>/auth/realms/<metersphere>/protocol/openid-connect/userinfo"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -136,8 +136,7 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item
|
<el-form-item :rules="requiredRules" prop="configuration.logoutUrl">
|
||||||
:rules="requiredRules">
|
|
||||||
<template v-slot:label>
|
<template v-slot:label>
|
||||||
Logout Endpoint
|
Logout Endpoint
|
||||||
<el-tooltip content="Logout redirect URL: http://<metersphere-endpoint>/sso/callback/logout"
|
<el-tooltip content="Logout redirect URL: http://<metersphere-endpoint>/sso/callback/logout"
|
||||||
|
@ -153,7 +152,7 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Client ID"
|
<el-form-item label="Client ID" prop="configuration.clientId"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules">
|
||||||
<el-input v-model="form.configuration.clientId" placeholder="eg: metersphere"/>
|
<el-input v-model="form.configuration.clientId" placeholder="eg: metersphere"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -161,7 +160,7 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Redirect URL"
|
<el-form-item label="Redirect URL" prop="configuration.redirectUrl"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules">
|
||||||
<el-input v-model="form.configuration.redirectUrl"
|
<el-input v-model="form.configuration.redirectUrl"
|
||||||
placeholder="eg: http://<metersphere-endpoint>/sso/callback or http://<metersphere-endpoint>/sso/callback/${authId}"/>
|
placeholder="eg: http://<metersphere-endpoint>/sso/callback or http://<metersphere-endpoint>/sso/callback/${authId}"/>
|
||||||
|
@ -171,7 +170,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Secret"
|
<el-form-item label="Secret"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules" prop="configuration.secret">
|
||||||
<el-input type="password" v-model="form.configuration.secret" show-password autocomplete="new-password"
|
<el-input type="password" v-model="form.configuration.secret" show-password autocomplete="new-password"
|
||||||
placeholder="OIDC client secret"/>
|
placeholder="OIDC client secret"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -181,7 +180,7 @@
|
||||||
<div class="node-line" v-if="form.type === 'OAuth2'">
|
<div class="node-line" v-if="form.type === 'OAuth2'">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Auth Endpoint"
|
<el-form-item label="Auth Endpoint" prop="configuration.authUrl"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules">
|
||||||
<el-input v-model="form.configuration.authUrl"
|
<el-input v-model="form.configuration.authUrl"
|
||||||
placeholder="eg: http://example.com/login/oauth/authorize"/>
|
placeholder="eg: http://example.com/login/oauth/authorize"/>
|
||||||
|
@ -191,7 +190,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Token Endpoint"
|
<el-form-item label="Token Endpoint"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules" prop="configuration.tokenUrl">
|
||||||
<el-input v-model="form.configuration.tokenUrl"
|
<el-input v-model="form.configuration.tokenUrl"
|
||||||
placeholder="eg: https://example.com/login/oauth/access_token"/>
|
placeholder="eg: https://example.com/login/oauth/access_token"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -200,7 +199,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Userinfo Endpoint"
|
<el-form-item label="Userinfo Endpoint"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules" prop="configuration.userInfoUrl">
|
||||||
<el-input v-model="form.configuration.userInfoUrl"
|
<el-input v-model="form.configuration.userInfoUrl"
|
||||||
placeholder="eg: https://example.com/user"/>
|
placeholder="eg: https://example.com/user"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -209,7 +208,7 @@
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Redirect URL"
|
<el-form-item label="Redirect URL"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules" prop="configuration.redirectUrl">
|
||||||
<el-input v-model="form.configuration.redirectUrl"
|
<el-input v-model="form.configuration.redirectUrl"
|
||||||
placeholder="eg: http://<metersphere-endpoint>/sso/callback/oauth2"/>
|
placeholder="eg: http://<metersphere-endpoint>/sso/callback/oauth2"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -217,7 +216,7 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Client ID"
|
<el-form-item label="Client ID" prop="configuration.clientId"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules">
|
||||||
<el-input v-model="form.configuration.clientId" placeholder="eg: metersphere"/>
|
<el-input v-model="form.configuration.clientId" placeholder="eg: metersphere"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -225,7 +224,7 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Secret"
|
<el-form-item label="Secret" prop="configuration.secret"
|
||||||
:rules="requiredRules">
|
:rules="requiredRules">
|
||||||
<el-input type="password" v-model="form.configuration.secret" show-password autocomplete="new-password"
|
<el-input type="password" v-model="form.configuration.secret" show-password autocomplete="new-password"
|
||||||
placeholder="oauth2 client secret"/>
|
placeholder="oauth2 client secret"/>
|
||||||
|
@ -234,14 +233,14 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Scope" :rules="requiredRules">
|
<el-form-item label="Scope" :rules="requiredRules" prop="configuration.scope">
|
||||||
<el-input v-model="form.configuration.scope"/>
|
<el-input v-model="form.configuration.scope"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col>
|
<el-col>
|
||||||
<el-form-item label="Property Mapping" :rules="requiredRules">
|
<el-form-item label="Property Mapping" :rules="requiredRules" prop="configuration.mapping">
|
||||||
<el-input v-model="form.configuration.mapping"
|
<el-input v-model="form.configuration.mapping"
|
||||||
:placeholder="mappingTip"/>
|
:placeholder="mappingTip"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -298,10 +297,10 @@ export default {
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
total: 0,
|
total: 0,
|
||||||
form: {configuration: {}},
|
form: {configuration: {}},
|
||||||
requiredRules: [{required: true, message: this.$t('test_resource_pool.fill_the_data'), trigger: 'blur'}],
|
requiredRules: [ {required: true, message: this.$t('test_resource_pool.fill_the_data'), trigger: ['blur']}],
|
||||||
rule: {
|
rule: {
|
||||||
name: [
|
name: [
|
||||||
{required: true, message: this.$t('test_resource_pool.input_pool_name'), trigger: 'blur'},
|
{required: true, message: this.$t('commons.input_name'), trigger: 'blur'},
|
||||||
{min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'},
|
{min: 2, max: 20, message: this.$t('commons.input_limit', [2, 20]), trigger: 'blur'},
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -381,46 +380,26 @@ export default {
|
||||||
this.$info(this.$t('commons.delete_cancel'));
|
this.$info(this.$t('commons.delete_cancel'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
changeAuthType(type) {
|
changeAuthType() {
|
||||||
|
this.form.configuration = {};
|
||||||
},
|
if (this.$refs.authSourceForm) {
|
||||||
validateInfo() {
|
this.$refs.authSourceForm.clearValidate();
|
||||||
let resultValidate = {validate: true, msg: this.$t('test_resource_pool.fill_the_data')};
|
|
||||||
let info = this.form.configuration;
|
|
||||||
for (let key in info) {
|
|
||||||
// Oauth2 logoutUrl 非必填
|
|
||||||
if (this.form.type === 'OAuth2' && key === 'logoutUrl') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (info[key] !== '0' && !info[key]) {
|
|
||||||
resultValidate.validate = false;
|
|
||||||
return resultValidate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resultValidate;
|
|
||||||
},
|
},
|
||||||
createAuthSource() {
|
createAuthSource() {
|
||||||
this.$refs.authSourceForm.validate(valid => {
|
this.$refs.authSourceForm.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
let vri = this.validateInfo();
|
let model = JSON.parse(JSON.stringify(this.form));
|
||||||
if (vri.validate) {
|
model.configuration = JSON.stringify(model.configuration);
|
||||||
let model = JSON.parse(JSON.stringify(this.form));
|
this.dialogLoading = addAuth(model)
|
||||||
model.configuration = JSON.stringify(model.configuration);
|
.then(() => {
|
||||||
this.dialogLoading = addAuth(model)
|
this.$message({
|
||||||
.then(() => {
|
type: 'success',
|
||||||
this.$message({
|
message: this.$t('commons.save_success')
|
||||||
type: 'success',
|
},
|
||||||
message: this.$t('commons.save_success')
|
this.dialogVisible = false,
|
||||||
},
|
this.initTableData());
|
||||||
this.dialogVisible = false,
|
});
|
||||||
this.initTableData());
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$warning(vri.msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -431,20 +410,14 @@ export default {
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let vri = this.validateInfo();
|
let model = JSON.parse(JSON.stringify(this.form));
|
||||||
if (vri.validate) {
|
model.configuration = JSON.stringify(model.configuration);
|
||||||
let model = JSON.parse(JSON.stringify(this.form));
|
this.dialogLoading = updateAuth(model)
|
||||||
model.configuration = JSON.stringify(model.configuration);
|
.then(() => {
|
||||||
this.dialogLoading = updateAuth(model)
|
this.$success(this.$t('commons.modify_success'));
|
||||||
.then(() => {
|
this.dialogVisible = false;
|
||||||
this.$success(this.$t('commons.modify_success'));
|
this.initTableData();
|
||||||
this.dialogVisible = false;
|
});
|
||||||
this.initTableData();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.$warning(vri.msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue