How should state be stored during oauth?

xuanbao · 2016-12-11 16:00:12 · 869 次点击    
这是一个分享于 2016-12-11 16:00:12 的资源,其中的信息可能已经有所发展或是发生改变。

I'm using golang.org/x/oauth2 and I'm not sure what the best way to store state it. I was looking into this a while ago and could have sworn I saw someone use net/context, but that wouldn't work would it because oauth is more than one request.


评论:

fqn:

I know Rails omniauth stores some state in the session. Have a look at that library for a good reference implementation.

captncraig:

I store it in a cookie. I set a short time to live on it, 5 minutes or so I think, and I sign/encrypt it with gorilla/securecookie.

ROFLLOLSTER:

Alright, thanks. Do you use gorilla/session or just stdlib?

captncraig:

I don't use gorilla/session as I don't really like the concept of a "session" at all. I just use securecookie to encode/verify and handle the cookie myself. I also make sure to delete the cookie after the callback is received.

ROFLLOLSTER:

Ok, thanks.

jasonrichardsmith:

JWT

ultra_brite:

store state ? what does it means ? context should only exists during the request's life time.

neoasterisk:

Hey! I thought you had deleted all your golang comments. Are you back?


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

869 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传