我有以下配置:
设计:database_authenticatable config.http_authenticatable = true
根据要求:
http://user:password@localhost:3000/
设计忽略 http 身份验证登录并重定向到登录页面
有什么想法吗?
问候
最佳答案
http_authenticatable 为您提供的是使用您的 HTTP 基本身份验证凭据登录到其自己的身份验证系统的能力。您仍然需要自己编写 http_auth block ,如下所示:
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "foo" && password == "bar"
end
warden.custom_failure! if performed?
end
此代码应该进入您的应用程序 Controller 。确保您使用的是 warden.custom_failure!,否则该设备将进入重定向的无限循环。
关于ruby-on-rails - 为html格式设计http基本认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7808646/