Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

前后端分离,单点登陆实现方式 #94

Open
m17y opened this issue May 24, 2019 · 0 comments
Open

前后端分离,单点登陆实现方式 #94

m17y opened this issue May 24, 2019 · 0 comments

Comments

@m17y
Copy link
Owner

m17y commented May 24, 2019

单点登陆

cas client与server验证

建议使用jwt作为验证数据的方式
server 生成jwt后重定向到client 并携带token
client 接收到token后 储存到localstore 或者保存到cookie
server 获取并验证token

跨域设置(已废弃)

1.后端跨域设置
{
    credentials: true,
    origin: 'http://10.235.171.233:4445'
   其他参数自行:google
}
2.前端跨域设置
    export async function getDeviceProfile(v) {
    return axios({
        url: 'http://10.235.171.233:9000/api/profile/bi/detail/'+v,
        method: 'get',
        withCredentials: true, //携带cookie 以便验证用户
    });
    }

jwt失效后后重新登陆的问题

server:验证cookie(jwt)失效或者没有登陆后,返回: 401 msg:faild
client:axios请求封装,请求异常统一处理 如果返回status code是401 则前端跳转到 cas登陆页面,如:
https://cas.test.cn/login?service=http://api.test.com/login?from=http://www.test.com
备注:
测试时,api.test.com www.test.com 请换陈自己前后端服务的完整url

相关文档

HTTP访问控制CORS详解
前端需要了解的 SSO 与 CAS 知识

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant