我有一个使用设计身份验证系统的 Rails 应用程序。还有另一个外部 Rails 应用程序请求此应用程序,但由于 application_controller 中的以下代码,它无法通过。
before_action :authenticate_user!
让应用程序正确进行身份验证并毫无问题地获得响应的最佳方式/设计是什么。
任何提示表示赞赏
最佳答案
您可以使用 token 身份验证来允许应用程序通过 URL 查询参数传递 secret token ,也可以使用 HTTP Basic Authentication 。
https://github.com/baschtl/devise-token_authenticatable
您需要创建一个用户帐户并为其生成一个 token ,并通过包含 ?tolen_param_name=SECRET
或使用 Http 基本身份验证与用户的用户名和密码。
http://railscasts.com/episodes/82-http-basic-authentication
请注意,通过 http 连接启用 ssl 来加密密码或 secret 会更安全。
关于ruby-on-rails - Rails 设计身份验证,外部应用程序请求被阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33443740/