doxd96148 2016-06-14 01:10
浏览 214

有没有办法在微服务前面实现SSO?

Recently I have a project to implement SSO(Single-Sign-On) for multiple web applications based on Beego Framework. The most popular SSO project is CAS, which needs a CAS Server in the center, and a CAS Client before each web application. Unfortunately, it seems that there's not any offical CAS clients written in Golang, except go-cas/cas, and adanteng/cas, which supports Beego.

But the workflow of CAS is a little bit complicated: too many redirections, too many tickets transmitted among the CAS, web apps, and the user browser. I can't figure out why people deploy the Authentication Services in the center of all the web apps, rather than the front, like the following diagram:

enter image description here

In this diagram, all the requests are forced to be processed in the Authenticate Service first, if authenticated successfully, then generate a session ID, saved in the cookies and Redis which is shared by other microservices. There's not any redirections or tickets at all, only requests transmittion.

So is this diagram possible, or some critical problems I ignored?

Update 0

The session-sharing way is indeed not scalable and modular as Nadh counsels. How about transmitting user information, like name, email, etc., in the headers of requests between the auth service and downstream services, like the creative work of Heipei at nginx-sso? Is it possible to make it work as an SSO Gateway as Sam Newman sharing in the book Building Microservices?

Update 1

A more detailed diagram is shown as follows, in order to describe my childish idea a little bit clearly, hoping that there is not much misunderstanding from Heipei and Sam Newman.

Rather than handling so many redirections and handshakes, all the requests are processed in the authentication service firstly, which writes user info from MySQL, into the Redis as the session provider, and the HTTP header to transmit to the downstream services, if the request is authenticated successfully.

In this way, the user info is transmitted via HTTP header instead of the above shared-Redis as Nadh warning, and Redis can be depolyed with the auth service, or shared among auth instances only.

enter image description here

Update 2

It seems that Cookie and Session are old-school techs. The cross-domain problem of cookie, and the sharing problem of session are the primary barrier to the scalability and flexibility of the modern web applications. Fortunately, JSON Web Token comes to be the best Single Sign-on solution for multiple lightweight services nowadays, by moving the user info(maybe id is enough) storage from the server side to the client side, and transmitted only if necessary.

  • 写回答

1条回答 默认 最新

  • dongyuan8024 2016-06-15 07:29
    关注

    But the workflow of CAS is a little bit complicated: too many redirections, too many tickets transmitted among the CAS, web apps, and the user browser. I can't figure out why people deploy the Authentication Services in the center of all the web apps, rather than the front, like the following diagram.

    You are thinking the old fashioned way, and thats why architects came up in the past with solutions like using portlet-servers for webapplications, session-shared-clusters, and lots of other heavy error-prone system-solutions which ate your cpu, memory or bandwith in ways which you could never predict until the first real life test.

    The CAS solution might look complicated on the first move, but you can predict how much logins, traffic and synchronisation data your system will generate and compared to the "old solutions", your system-to-user load will raise linear and not exponential.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题