douwaif22244 2016-05-13 07:35
浏览 182
已采纳

Golang中的单点登录身份验证

I am trying to build a multi-tenant architecture in golang where there will be different services like Service-A and Service-B each service will run on a different server and I want the user to have a single sign-in solution and get authenticated in all the services offered.

Just like what Amazon AWS or Google does like it has many different services like Amazon Cloud Front, Amazon EC2, Amazon S3 and all services are authenticated through a single login and logout from one service result inlog out from all connected services.

I am trying to implement this in golang, so far I found out Open-id Connect coreos/dex but it lacks docs explaining its API and Architecture.

What would be the best architecture to design such authentication system?

I think using JWT token I can achieve it. Is this architecture will be secure or there any better solution for this?

My Approach

                          -----------------        
                          |               |    shared
                          |               |   env file
                          |SERVICES A     |---------------|       
           AUTH HEADER    |               |               |
           JWT TOKEN      |               |               |
        |---------------> -----------------               |                     
    ---------            ------------------   shared      |
    |       |            |    SERVICE B   |  env file     |                    
    |Login  | -----------|                |-----------    |               
    |Browser|            |                |          |    |  
    ---------            ------------------          |    |
        | |                                          |    |   
   Login| |"JWT_TOKEN RESPONSE"                      |    |   
        | |                                          |    |   
    --------------   enviroment file                ------------   
    |            |----------------------------------|          |
    | Main Server|                                  |          |
    |            |                                  |JWT_SECRET|    
    --------------                                  |="secret" |          
                                                    ------------
  • 写回答

1条回答 默认 最新

  • drnf593779 2016-05-13 15:10
    关注

    While your solution will certainly work. It could make writing the browser/mobile/general frontend part of your application more complex. And possibly slower.

    For example you might end up effectively JOINing data in the frontend. You make one request to service A, then use the information returned there to make additional requests to service B. This is a bad experience for the user.

    Once new concept that companies like Netflix and Soundcloud are pioneering is the backend for frontend pattern. Which is a server side adaptor for each type of frontend device that can handle authentication and aggregate the connections to the down stream services.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。