如何使用 RESTful_authentication gem 对一个 Ruby on Rails 应用程序进行身份验证?

发布于 2024-07-27 12:40:55 字数 136 浏览 2 评论 0原文

有人有什么想法吗? 情况是这样的:我有一个主要的 Rails 应用程序和一个辅助的应用程序。 辅助应用程序用于将 Web 服务请求转换为对主应用程序的 RESTful PUT。 辅助应用程序尝试添加的资源需要身份验证。 任何想法将不胜感激! 谢谢!

Anybody have any ideas? The situation is like this: I have a primary rails app and an auxiliary one. The auxiliary app is used to transform a web service request into a RESTful PUT to the main app. The resource the auxiliary app is attempting to add to requires authentication. Any ideas would be much appreciated! Thanks SO!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蛮可爱 2024-08-03 12:40:55

ActiveResource 用于此目的:

class MyModel < ActiveResource::Base
  self.site = OTHER_APP_URL
  self.user = OTHER_APP_USER
  self.password = OTHER_APP_PASSWORD

  # Rest of the code here
end

在此处阅读如何从 ActiveResource 与 RESTful API 对话: http://api.rubyonrails.org/classes/ActiveResource/Base.html

ActiveResource is used for this purpose:

class MyModel < ActiveResource::Base
  self.site = OTHER_APP_URL
  self.user = OTHER_APP_USER
  self.password = OTHER_APP_PASSWORD

  # Rest of the code here
end

Read up on how to talk to RESTful API from ActiveResource here: http://api.rubyonrails.org/classes/ActiveResource/Base.html

野の 2024-08-03 12:40:55

我想我可能通过调查我的一些即时通讯联系人找到了自己的答案。 最合乎逻辑的方法是使用 Curb ruby​​ gem。 从上述 API 中,只需启用 cookie jar,安全地进行身份验证,然后将 cookie 包含在需要身份验证的后续 HTTP 操作中;)

(当我实现此功能时,将发布一些代码..)

不过,仍然感谢评论和/或替代方案!

I think I may have found my own answer by polling some of my IM contacts. The most logical approach is to use the Curb ruby gem. From the aforementioned API, one simply enables the cookie jar, restfully authenticates and then includes the cookie in subsequent HTTP actions requiring authentication ;)

(Will post some code when I get this implemented..)

Would still appreciate comments and or alternatives though!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文