我有一个使用设计认证系统的rails应用程序。还有另一个外部rails应用程序请求此应用程序,但由于application_controller中的代码,它无法通过。
before_action :authenticate_user!
让应用程序正确进行身份验证并在没有问题的情况下获得响应的最佳方法/设计是什么。
赞赏任何提示
答案 0 :(得分:2)
You can either use token authentication to allow the app to pass a secret token via a url query parameter or use HTTP Basic Authentication.
https://github.com/baschtl/devise-token_authenticatable
You would need to create a user account and generate a token for it and use that token for every request that your app makes by either including ?tolen_param_name=SECRET
or use Http basic authentication with the user's username and password.
http://railscasts.com/episodes/82-http-basic-authentication
Note that it's safer to enable ssl over the http connection to encrypt the password or secret.