fix: 跳转到 / 不用校验csrf
This commit is contained in:
parent
7c40fa3377
commit
808f9de68b
|
@ -49,6 +49,7 @@ public class ShiroConfig implements EnvironmentAware {
|
||||||
Map<String, String> filterChainDefinitionMap = shiroFilterFactoryBean.getFilterChainDefinitionMap();
|
Map<String, String> filterChainDefinitionMap = shiroFilterFactoryBean.getFilterChainDefinitionMap();
|
||||||
ShiroUtils.loadBaseFilterChain(filterChainDefinitionMap);
|
ShiroUtils.loadBaseFilterChain(filterChainDefinitionMap);
|
||||||
|
|
||||||
|
filterChainDefinitionMap.put("/", "apikey, authc"); // 跳转到 / 不用校验 csrf
|
||||||
filterChainDefinitionMap.put("/**", "apikey, csrf, authc");
|
filterChainDefinitionMap.put("/**", "apikey, csrf, authc");
|
||||||
return shiroFilterFactoryBean;
|
return shiroFilterFactoryBean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import MsUser from "./components/common/head/HeaderUser";
|
||||||
import MsHeaderOrgWs from "./components/common/head/HeaderOrgWs";
|
import MsHeaderOrgWs from "./components/common/head/HeaderOrgWs";
|
||||||
import MsLanguageSwitch from "./components/common/head/LanguageSwitch";
|
import MsLanguageSwitch from "./components/common/head/LanguageSwitch";
|
||||||
import {saveLocalStorage} from "@/common/js/utils";
|
import {saveLocalStorage} from "@/common/js/utils";
|
||||||
|
import {registerRequestHeaders} from "@/common/js/ajax";
|
||||||
|
|
||||||
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
|
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
|
||||||
const header = requireComponent.keys().length > 0 ? requireComponent("./license/LicenseMessage.vue") : {};
|
const header = requireComponent.keys().length > 0 ? requireComponent("./license/LicenseMessage.vue") : {};
|
||||||
|
@ -53,6 +54,7 @@ export default {
|
||||||
window.addEventListener("beforeunload", () => {
|
window.addEventListener("beforeunload", () => {
|
||||||
localStorage.setItem("store", JSON.stringify(this.$store.state))
|
localStorage.setItem("store", JSON.stringify(this.$store.state))
|
||||||
})
|
})
|
||||||
|
registerRequestHeaders();
|
||||||
},
|
},
|
||||||
beforeCreate() {
|
beforeCreate() {
|
||||||
this.$get("/isLogin").then(response => {
|
this.$get("/isLogin").then(response => {
|
||||||
|
|
|
@ -3,6 +3,16 @@ import axios from "axios";
|
||||||
import i18n from '../../i18n/i18n'
|
import i18n from '../../i18n/i18n'
|
||||||
import {TokenKey} from "@/common/js/constants";
|
import {TokenKey} from "@/common/js/constants";
|
||||||
|
|
||||||
|
export function registerRequestHeaders() {
|
||||||
|
axios.interceptors.request.use(config => {
|
||||||
|
let user = JSON.parse(localStorage.getItem(TokenKey));
|
||||||
|
if (user && user.csrfToken) {
|
||||||
|
config.headers['CSRF-TOKEN'] = user.csrfToken;
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(Vue) {
|
install(Vue) {
|
||||||
|
|
||||||
|
@ -40,15 +50,6 @@ export default {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
axios.interceptors.request.use(config => {
|
|
||||||
let user = JSON.parse(localStorage.getItem(TokenKey));
|
|
||||||
if (user && user.csrfToken) {
|
|
||||||
config.headers['CSRF-TOKEN'] = user.csrfToken;
|
|
||||||
}
|
|
||||||
return config;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
function then(success, response, result) {
|
function then(success, response, result) {
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
success(response);
|
success(response);
|
||||||
|
|
Loading…
Reference in New Issue