【问题标题】:Devise and basic auth设计和基本身份验证
【发布时间】:2010-09-10 21:23:03
【问题描述】:

您能否告诉我 - 是否可以为一个或多个控制器/动作禁用守望者/设计?

我需要允许向其中一个控制器发送具有基本身份验证的请求,但每次我发送类似的请求时,我都会发送种子消息,我的应用不需要基本身份验证。

我正在编写 oauth2 提供程序,但允许客户端应用程序使用基本身份验证发送他的凭据是一个问题,如此处所述 - https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-08#section-2

【问题讨论】:

  • 请不要在 Stack Overflow 上使用“plz”。

标签: ruby-on-rails ruby security devise basic-authentication


【解决方案1】:

如果您在 ApplicationController 中执行 before_filter :authenticate_user!,只需在要禁用设计的控制器中执行 skip_before_filter :authenticate_user!

【讨论】:

    【解决方案2】:

    直接回答您的问题 - 如果您不想对特定控制器进行身份验证,则只需省略或删除 'before_filter :authenticate_user!statement in that controller. Similarly, if you want to do authentication for only certain methods in the controller, look at the:onlyand:exceptoptions tobefore_filter`。

    如果您希望允许特定方法或控制器的 http 身份验证,那么我相信您必须重写一些设计方法以限制仅 http 身份验证,因为设计想要默认情况下灵活,将允许 http auth 或 session auth。

    【讨论】:

      猜你喜欢
      • 2016-10-31
      • 2011-01-28
      • 1970-01-01
      • 1970-01-01
      • 2021-07-29
      • 2021-01-28
      • 2016-08-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多