赞
踩
单点登录认证:访问A系统,在B系统登录认证
此处代码为A系统
@ResponseBody
@GetMapping("/idp/loginCheck")
public void loginCheck(HttpServletRequest request, HttpServletResponse httpResponse) throws IOException {
// bam 的服务器地址
String amUrl = "https://www.baidu.com/";
// 应用注册的唯一标识
String clientId = "client_test";
// 应用回调地址
String redirectURI = request.getRequestURI();
String requestUrl = amUrl + "?client_id=" + clientId
+ "&redirect_uri=" + redirectURI + "&response_type=code&state=" + state;
httpResponse.sendRedirect(requestUrl);
}
export function loginCheck() {
return http.get('/idp/loginCheck')
}
import { loginCheck } from '@/api/idp/idp'
router.beforeEach(async(to, from, next) => {
loginCheck().then(resp => {
if ('ok' === resp.data.msg) {
// 跳转首页或者原跳转前页面
// this.$router.push({ path: '/' });
console.log("11111")
} else {
console.log("88888888888888888")
}
})
})
前端中访问后台接口的方式修改为:
window.location.href = `/idp/loginCheck`;
前面也试了nginx添加跨域配置、拦截器添加配置,都不生效,奇怪
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。