Rails中的设计和无状态令牌 [英] Devise and Stateless tokens in Rails

查看:120
本文介绍了Rails中的设计和无状态令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我使用Rails 3和Devise开发的API。我正在使用令牌(token_authenticatable)来验证从客户端到API的请求。我想要在请求中的用户之间切换,只是替换令牌。



我听说过一个名为stateless_token(boolean)的设置,但是我无法弄清楚哪里放这个设置。有没有另一种方法?



如果在这里找到token_authenticatable:



https://github.com/plataformatec/devise/blob/master/lib/devise/strategies /token_authenticatable.rb



如果在这里找到有关stateless_token的信息:



http://rdoc.info/github/plataformatec/devise/master/Devise/Models/ TokenAuthenticatable

解决方案

stateless_token 现在已被弃用。这是新形式(它允许更多的认证策略成为无状态):

 #config / initializers / devise.rb 
config.skip_session_storage = [:token_auth]


I got an API that I have developed using Rails 3 and Devise. I am using tokens (token_authenticatable) for authentication for requests made to the API from a client. I want to be able to switch between users in the requests just be replacing the token.

I heard about a setting called :stateless_token (boolean) but I cannot figure out where to put this setting. Is there another way?

If found the token_authenticatable here:

https://github.com/plataformatec/devise/blob/master/lib/devise/strategies/token_authenticatable.rb

If found info about the stateless_token here:

http://rdoc.info/github/plataformatec/devise/master/Devise/Models/TokenAuthenticatable

解决方案

stateless_token is deprecated as of now. This is the new form (it allows more auth strategies to be stateless):

# config/initializers/devise.rb
config.skip_session_storage = [:token_auth]

这篇关于Rails中的设计和无状态令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆