omniauth 与 oauth 插件
我试图找出omniauth之间的差异(https://github.com/intridea/omniauth ) 和 oauth-plugin - (https://github.com/pelle/oauth-plugin)
我只是在寻找一种方法来允许我的用户在我的应用程序中使用(Twitter、Facebook 等)进行身份验证。
我知道omniauth提供了这个,但我正在运行rails 2.3.10,我不相信omniauth支持它。我可以使用 oauth 插件吗?它的依赖性似乎也少了很多。任何想法表示赞赏。
I'm trying to figure out the differences between omniauth (https://github.com/intridea/omniauth) and oauth-plugin - (https://github.com/pelle/oauth-plugin)
I'm simply looking for a way to allow my users to authenticate with (Twitter, Facebook, etc) within my app.
I know omniauth provides this, but I'm running rails 2.3.10 which I don't believe is supported by omniauth. Can I use oauth-plugin? It also seems to have a lot fewer dependencies. Any thoughts are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不得不不同意前面的答案。
oauth-plugin
是它提供了两个生成器(一个用于实现 OAuth 提供程序,一个为消费者)创建模型、视图和控制器。控制器的工作方式是,它们是 gem 中定义的控制器的子类。它与 Rails 的联系非常紧密,并且只能进行 OAuth。
另一方面,omniauth 是一个与框架无关的模块化库,允许您通过多个提供程序提供身份验证。
具体来说,这意味着您设置两个端点(
/auth/:provider
和/auth/:provider/callback
),让您的用户向提供商进行身份验证,并接收返回用户信息的哈希值。TL;DR
如果您只需要通过 Facebook/Twitter/OAuth/etc 提供身份验证(即您想成为 OAuth 消费者),那么
omniauth 绝对是更轻量级的。
如果您想运行 OAuth 提供程序,
oauth-plugin
可能更简单,但在我看来,它往往更加臃肿,因为它会向您的系统中注入大量样板代码。应用程序。I have to disagree with the previous answers.
oauth-plugin
isIt provides two generators (one for implementing an OAuth provider, one for the consumer) which create the models, the views and the controllers. The way the controllers work, is that they are subclasses of controllers defined in the gem. It's tied into Rails pretty deeply, and can only do OAuth.
omniauth
, on the other hand, is a modular, framework-agnostic library that allows you to provide authentication via a multitude of providers.Concretely, it means that you set up two endpoints (
/auth/:provider
and/auth/:provider/callback
), have your user authenticate with the provider, and receive a hash with the user's info in return.TL;DR
If you only need to provide authentication via Facebook/Twitter/OAuth/etc (i.e. you want to be an OAuth consumer), then
omniauth
is definitely more lightweight.If you want to run an OAuth provider,
oauth-plugin
might be more straightforward, but it tends to be a lot more bloated, in my opinion, since it injects a lot of boiler-plate code into your app.Omniauth 是一个超级授权宝石,让您可以访问整个 Web 服务列表(Twitter、Facebook、Foursquare、Gowalla、Netflix、YouTube 等)的 OAuth 流程,因此您可以为每个服务调用特定的函数,快速设置。
您提到的 oauth-plugin 似乎只是为您设置了 OAuth 常规设置,并且您必须自己为每个服务进行 API 连接。更轻量级,因此,例如,如果您只需要 Twitter 服务,这可能是一个更好的方法,尽管我仍然可能会查看 Omniauth 以了解它的性能消耗有多大,因为它会很大整体上更容易使用。
Omniauth is a mega-authorization gem, giving you access to the OAuth processes for a whole list of web services (Twitter, Facebook, Foursquare, Gowalla, Netflix, YouTube, etc, etc), so you can call specific functions for each service and get it set up quickly.
The oauth-plugin you mention appears to just set you up with an OAuth general setup, and you'd have to do the API hookups for each service yourself. More lightweight, so if you only need Twitter services, for example, that might be a better way to go, although I'd still probably check out Omniauth to see how big of a performance drain it is, because it's going to be a lot easier to use overall.