forked from github/dataease
fix(登出): oidc宕机后无法退出系统
This commit is contained in:
parent
0cb0e3ff79
commit
ee32305816
@ -12,6 +12,7 @@ import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.auth.util.RsaUtil;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.sys.request.LdapAddRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
@ -240,8 +241,13 @@ public class AuthServer implements AuthApi {
|
||||
HttpServletRequest request = ServletUtils.request();
|
||||
String idToken = request.getHeader("IdToken");
|
||||
if (StringUtils.isNotBlank(idToken)) {
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
oidcXpackService.logout(idToken);
|
||||
try {
|
||||
OidcXpackService oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
oidcXpackService.logout(idToken);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("oidc_logout_error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,11 +259,16 @@ public class AuthServer implements AuthApi {
|
||||
String result = null;
|
||||
Integer defaultLoginType = systemParameterService.defaultLoginType();
|
||||
if (defaultLoginType == 3 && isOpenCas()) {
|
||||
HttpServletRequest request = ServletUtils.request();
|
||||
HttpSession session = request.getSession();
|
||||
session.invalidate();
|
||||
CasXpackService casXpackService = SpringContextUtil.getBean(CasXpackService.class);
|
||||
result = casXpackService.logout();
|
||||
try {
|
||||
HttpServletRequest request = ServletUtils.request();
|
||||
HttpSession session = request.getSession();
|
||||
session.invalidate();
|
||||
CasXpackService casXpackService = SpringContextUtil.getBean(CasXpackService.class);
|
||||
result = casXpackService.logout();
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("cas_logout_error");
|
||||
}
|
||||
}
|
||||
try {
|
||||
Long userId = JWTUtils.tokenInfoByToken(token).getUserId();
|
||||
|
@ -18,14 +18,16 @@ export function getInfo(token) {
|
||||
export function logout() {
|
||||
return request({
|
||||
url: '/api/auth/logout',
|
||||
method: 'post'
|
||||
method: 'post',
|
||||
hideMsg: true
|
||||
})
|
||||
}
|
||||
|
||||
export function deLogout() {
|
||||
return request({
|
||||
url: '/api/auth/deLogout',
|
||||
method: 'post'
|
||||
method: 'post',
|
||||
hideMsg: true
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2626,5 +2626,9 @@ export default {
|
||||
apply_logs: 'Apply logs',
|
||||
app_group_delete_tips: 'Are you sure to delete this application category?',
|
||||
app_group_delete_content: 'After deletion, all application templates in this category will also be deleted.'
|
||||
},
|
||||
logout: {
|
||||
oidc_logout_error: 'OIDC failed to exit, do you continue to exit DataEase?',
|
||||
cas_logout_error: 'CAS服务异常,请联系管理员!'
|
||||
}
|
||||
}
|
||||
|
@ -2627,5 +2627,9 @@ export default {
|
||||
apply_logs: '應用記錄',
|
||||
app_group_delete_tips: '確定刪除該應用分類嗎?',
|
||||
app_group_delete_content: '刪除後,該分類中所有的應用模闆也將被刪除。'
|
||||
},
|
||||
logout: {
|
||||
oidc_logout_error: 'OIDC退出失敗,是否繼續退出DataEase?',
|
||||
cas_logout_error: 'CAS服務異常,請聯系管理員!'
|
||||
}
|
||||
}
|
||||
|
@ -2627,5 +2627,9 @@ export default {
|
||||
apply_logs: '应用记录',
|
||||
app_group_delete_tips: '确定删除该应用分类吗?',
|
||||
app_group_delete_content: '删除后,该分类中所有的应用模板也将被删除。'
|
||||
},
|
||||
logout: {
|
||||
oidc_logout_error: 'OIDC退出失败,是否继续退出DataEase?',
|
||||
cas_logout_error: 'The CAS service is abnormal, please contact the administrator!'
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import { getLanguage } from '@/lang/index'
|
||||
import Cookies from 'js-cookie'
|
||||
import router from '@/router'
|
||||
import i18n from '@/lang'
|
||||
import { $alert, $confirm } from '@/utils/message'
|
||||
const getDefaultState = () => {
|
||||
return {
|
||||
token: getToken(),
|
||||
@ -146,6 +147,28 @@ const actions = {
|
||||
resolve(res.data)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
if (error?.response?.data?.message) {
|
||||
if (error.response.data.message === ('oidc_logout_error')) {
|
||||
const message = i18n.t('logout.' + error.response.data.message)
|
||||
$confirm(message, () => {
|
||||
removeToken() // must remove token first
|
||||
resetRouter()
|
||||
commit('RESET_STATE')
|
||||
window.location.href = '/'
|
||||
}, {
|
||||
confirmButtonText: i18n.t('commons.confirm')
|
||||
})
|
||||
}
|
||||
if (error.response.data.message === ('cas_logout_error')) {
|
||||
const message = i18n.t('logout.' + error.response.data.message)
|
||||
$alert(message, () => {
|
||||
|
||||
}, {
|
||||
confirmButtonText: i18n.t('commons.confirm'),
|
||||
showClose: false
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user