ruby-on-rails – 在rails响应中设置WWW-Authenticate标头的正确
发布时间:2020-12-17 02:12:32 所属栏目:百科 来源:网络整理
导读:在rails响应中设置WWW-Authenticate标头的正确方法是什么? 目前我是这样做的: headers["WWW-Authenticate"] = %(Basic realm="My Realm") render :json = {:message =I18n.t("errors.messages.authorization_error")},:status = :unauthorized 我认为使用r
在rails响应中设置WWW-Authenticate标头的正确方法是什么?
目前我是这样做的: headers["WWW-Authenticate"] = %(Basic realm="My Realm") render :json => {:message =>I18n.t("errors.messages.authorization_error")},:status => :unauthorized 我认为使用rails api设置此标头有一种更简单的方法.无需直接访问标题字典. 解决方法
您正在做的事情没有任何问题,但是rails确实已经进行了HTTP身份验证.请参阅此链接:
http://apidock.com/rails/ActionController/HttpAuthentication/Basic/ControllerMethods/authenticate_or_request_with_http_basic
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容