标签: http-token-authentication

DeviseTokenAuth控制器的强参数覆盖

我在Rails 4.2上使用了devise-token-auth gem,并且我nicknameUser模型中添加了一个字段.我试图通过覆盖gem控制器来实现这一点

class Users::RegistrationsController < DeviseTokenAuth::RegistrationsController

  before_filter :configure_permitted_parameters

  def update
    #this line never shows in the logs
    Rails.logger.info "I never get to run!!"
    super
  end

  protected

  # my new custom field is :nickname
  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) do |u|
      u.permit(:name, :nickname,
        :email, :password, :password_confirmation)
    end
    devise_parameter_sanitizer.for(:account_update) do |u|
      u.permit(:name,
        :email, :password, :password_confirmation, :nickname)
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

路由配置如下:

  Rails.application.routes.draw do
    namespace :api, constraints: { format: 'json' } do
        mount_devise_token_auth_for 'User', at: 'auth', controllers: {
          registrations:  'users/registrations' …
Run Code Online (Sandbox Code Playgroud)

devise ruby-on-rails-4 http-token-authentication ruby-on-rails-4.2

3
推荐指数
1
解决办法
2120
查看次数

JWT和CSRF的区别

我一直在阅读有关JWT的内容,据我了解,它是服务器在用户登录后发送的令牌,用户将必须在以后所有http请求中发送该令牌,这为服务器验证用户提供了一种无状态方式请求。现在我不明白的是,如果jwt在标头中发送并仅标记为http,为什么还需要一个csrf令牌来防止csrf攻击?我的理解是jwt和csrf令牌都是与用户绑定的令牌,从我的理解来看,jwt可以满足两个目的吗?我知道使用csrf令牌,因此不会接受来自其他站点的http请求,而jwt怎么不能做到这一点?什么将csrf令牌与jwt令牌分开以实现这种差异?我一直在阅读有关jwt和csrf令牌以及双提交方法的文章,

csrf jwt http-token-authentication

3
推荐指数
1
解决办法
2869
查看次数

csrf_token 显示为 URL 参数

网站可以将 csrf_token 显示为 URL 参数吗?我有一种感觉,我应该看不到它,但我不太确定。如果有人能澄清这一点,我将不胜感激!

security http-token-authentication

3
推荐指数
1
解决办法
2706
查看次数

2
推荐指数
2
解决办法
1878
查看次数

使用HttpUrlConnection发送标头值

我试图使用身份验证值向服务器发送响应,它在登录时提供给我.服务器仅在发送该值时接受请求.但它适用于邮递员(见快照)但不适用于我的代码.

 URL url = new URL(strings[0]);
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            String token = "" + new String(accessToken);
            con.setRequestMethod("GET");
            con.setRequestProperty("AuthToken", token);
            con.setReadTimeout(15000);
            con.setConnectTimeout(15000);
            con.setDoOutput(false);
Run Code Online (Sandbox Code Playgroud)

我也试过这样的方式

String token = "AuthToken :" + new String(accessToken);
con.setRequestProperty("Authorization", token);
Run Code Online (Sandbox Code Playgroud)

android get httpurlconnection http-token-authentication

1
推荐指数
1
解决办法
9098
查看次数