doudongfu8006 2015-07-20 14:00
浏览 14
已采纳

API认证设计

I'm planning on building a web service consisting of two servers - an API backend (RESTful & stateless) and a web server frontend. The backend will be build with Go and the web server with PHP or Java.

Basically I'd like multiple users to log in with their web browsers through the use of their facebook or google credentials which I understand I must use OAuth for.

I'm however deeply confused about how I should design the authentication. Can I simply implement OAuth on the webserver alone and then use an API-key/secret to validate the webserver with my API and communicate over an encrypted connection between the two of them. Would that be secure and work just fine or should I implement authentication in some other way?

I've made a simple diregram showing my idea of how this could be done.

Authentication diagram

I really hope that you guys can point me in the right direction.

  • 写回答

1条回答 默认 最新

  • 普通网友 2015-07-20 14:06
    关注

    Two common approached to tacking the problem:

    Trusted subsystem model vs Delegation model

    Trusted subsystem

    Use a trusted subsystem model, it maybe impractical to maintain a separate key and secret for every user of the front end, the trusted subsystem model basically states that a system (web server) with authority to an api is responsible or trusted to authenticate/authorise users access to that api, and is given authority to do so.

    What you do is provision a account for the web server, and allow the web server to authorize access to the api.

    Delegation model

    If you have control over how the api authenticates you can use the same method as the frontend and reuse the end users security principal to authenticate to the back end api.

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

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料