dongyin8009 2014-08-22 11:14
浏览 361

Cookie中的OAuth2授权代码,好还是不好?

I can not seem to find a SIMPLE answer to the question on how to persist OAuth2 authentication... Let's take Google+ OAuth2 API as an example.

  1. User goes to page
  2. User is not authenticated, and gets redirected to authentication page where he logs in
  3. User logs in successfully and authorises my app
  4. User gets redirect to specified (by me) URI with Authorisation Code
  5. I use authorisation code to obtain a token in order to submit queries in the name of the user

All is good and well. My question is: how do you SECURELY know at step 2 that the user visiting the page is already logged in, without having to go through the whole process of redirecting him to all these pages.

I assume storing the Authorisation Code retrieved at step 4 in a cookie is not an option.

All of this will happen in a server-side (Go - if that matters) application. Any help is much appreciated... I need a simple solution.

Thank you!

  • 写回答

1条回答 默认 最新

  • douza19870617 2014-12-27 09:15
    关注

    use server-side sessions to store any authentication state or even access tokens if you need them.

    one solution is to use a database for session store (an encrypted cookie holds the session id) and another is to use cookie sessions (encrypted cookies that hold the session data). using encrypted cookies that only the server is able to decrypt should be safe enough.

    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?