fix(系统设置): 登录认证源被关闭后依然可以进行认证的问题
--bug=1020042 --user=李玉号 【系统设置】禁用OAuth2-登录ms一直是加载状态 https://www.tapd.cn/55049933/s/1301188
This commit is contained in:
parent
d16ef035c7
commit
3ff7a340a1
|
@ -119,6 +119,10 @@ public class LoginController {
|
|||
return Mono.just(ResultHolder.success(authSourceService.listAllEnable()));
|
||||
}
|
||||
|
||||
@GetMapping("authsource/{authId}")
|
||||
public Mono<ResultHolder> getAuthSource(@PathVariable("authId") String authId) {
|
||||
return Mono.just(ResultHolder.success(authSourceService.getAuthSource(authId)));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/services")
|
||||
public Mono<ResultHolder> getServices() {
|
||||
|
|
|
@ -57,6 +57,10 @@ export function getAuthSources() {
|
|||
return get('/authsource/list/allenable')
|
||||
}
|
||||
|
||||
export function getAuthSource(id) {
|
||||
return get('/authsource/' + id)
|
||||
}
|
||||
|
||||
export function getProjectMemberOption() {
|
||||
return get('/user/project/member/option');
|
||||
}
|
||||
|
|
|
@ -59,9 +59,17 @@
|
|||
|
||||
<script>
|
||||
import {getCurrentUserId, publicKeyEncrypt} from "../../utils/token";
|
||||
import {CURRENT_LANGUAGE, DEFAULT_LANGUAGE, PRIMARY_COLOR} from "../../utils/constants";
|
||||
import {DEFAULT_LANGUAGE, PRIMARY_COLOR} from "../../utils/constants";
|
||||
import {hasLicense, hasPermissions, saveLicense} from "../../utils/permission";
|
||||
import {checkLdapOpen, getAuthSources, getDisplayInfo, getLanguage, getSystemTheme, saveBaseUrl} from "../../api/user";
|
||||
import {
|
||||
checkLdapOpen,
|
||||
getAuthSource,
|
||||
getAuthSources,
|
||||
getDisplayInfo,
|
||||
getLanguage,
|
||||
getSystemTheme,
|
||||
saveBaseUrl
|
||||
} from "../../api/user";
|
||||
import {useUserStore} from "@/store"
|
||||
import {checkMicroMode, operationConfirm} from "../../utils";
|
||||
import {getModuleList} from "../../api/module";
|
||||
|
@ -291,38 +299,47 @@ export default {
|
|||
if (authId === 'LDAP' || authId === 'LOCAL') {
|
||||
return;
|
||||
}
|
||||
let source = this.authSources.filter(auth => auth.id === authId)[0];
|
||||
// 以前的cas登录
|
||||
if (source.type === 'CAS') {
|
||||
let config = JSON.parse(source.configuration);
|
||||
if (config.casServerUrl && !config.loginUrl) {
|
||||
getAuthSource(authId).then(res => {
|
||||
if (!res || !res.data) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
operationConfirm(this, this.$t('commons.auth_redirect_tip'), () => {
|
||||
let config = JSON.parse(source.configuration);
|
||||
let redirectUrl = eval('`' + config.redirectUrl + '`');
|
||||
let url;
|
||||
if (res.data.status !== 'ENABLE') {
|
||||
this.$message.error(this.$t('login.auth_not_enable'));
|
||||
return;
|
||||
}
|
||||
let source = this.authSources.filter(auth => auth.id === authId)[0];
|
||||
// 以前的cas登录
|
||||
if (source.type === 'CAS') {
|
||||
url = config.loginUrl + "?service=" + encodeURIComponent(redirectUrl);
|
||||
let config = JSON.parse(source.configuration);
|
||||
if (config.casServerUrl && !config.loginUrl) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (source.type === 'OIDC') {
|
||||
url = config.authUrl + "?client_id=" + config.clientId + "&redirect_uri=" + redirectUrl +
|
||||
"&response_type=code&scope=openid+profile+email&state=" + authId;
|
||||
}
|
||||
if (source.type === 'OAuth2') {
|
||||
url = config.authUrl
|
||||
+ "?client_id=" + config.clientId
|
||||
+ "&scope=" + config.scope
|
||||
+ "&response_type=code"
|
||||
+ "&redirect_uri=" + redirectUrl
|
||||
+ "&state=" + authId;
|
||||
}
|
||||
if (url) {
|
||||
window.location.href = url;
|
||||
}
|
||||
}, () => {
|
||||
this.form.authenticate = 'LOCAL';
|
||||
operationConfirm(this, this.$t('commons.auth_redirect_tip'), () => {
|
||||
let config = JSON.parse(source.configuration);
|
||||
let redirectUrl = eval('`' + config.redirectUrl + '`');
|
||||
let url;
|
||||
if (source.type === 'CAS') {
|
||||
url = config.loginUrl + "?service=" + encodeURIComponent(redirectUrl);
|
||||
}
|
||||
if (source.type === 'OIDC') {
|
||||
url = config.authUrl + "?client_id=" + config.clientId + "&redirect_uri=" + redirectUrl +
|
||||
"&response_type=code&scope=openid+profile+email&state=" + authId;
|
||||
}
|
||||
if (source.type === 'OAuth2') {
|
||||
url = config.authUrl
|
||||
+ "?client_id=" + config.clientId
|
||||
+ "&scope=" + config.scope
|
||||
+ "&response_type=code"
|
||||
+ "&redirect_uri=" + redirectUrl
|
||||
+ "&state=" + authId;
|
||||
}
|
||||
if (url) {
|
||||
window.location.href = url;
|
||||
}
|
||||
}, () => {
|
||||
this.form.authenticate = 'LOCAL';
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
|
|
|
@ -490,6 +490,7 @@ const message = {
|
|||
},
|
||||
login: {
|
||||
normal_Login: "Normal Login",
|
||||
auth_not_enable: "Authentication is not enabled"
|
||||
},
|
||||
license: {
|
||||
title: 'Authorization management',
|
||||
|
|
|
@ -493,6 +493,7 @@ const message = {
|
|||
},
|
||||
login: {
|
||||
normal_Login: "普通登录",
|
||||
auth_not_enable: "认证未开启"
|
||||
},
|
||||
license: {
|
||||
title: '授权管理',
|
||||
|
|
|
@ -493,6 +493,7 @@ const message = {
|
|||
},
|
||||
login: {
|
||||
normal_Login: "普通登錄",
|
||||
auth_not_enable: "認證未開啟"
|
||||
},
|
||||
license: {
|
||||
title: '授權管理',
|
||||
|
|
Loading…
Reference in New Issue