Ruby-on-rails Rails 3. 构建一个 oauth2 提供者

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4900300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 00:19:34  来源:igfitidea点击:

Rails 3. Building an oauth2 provider

ruby-on-railsruby-on-rails-3oauth-2.0

提问by Jonathan Clark

I am developing an API in Ruby on Rails 3 and I would like to secure it with Oauth2. In other words, I need to create an Oauth provider. Is there a working gem for Rails 3 out there or perhaps a tutorial on the issue?

我正在 Ruby on Rails 3 中开发 API,我想用 Oauth2 保护它。换句话说,我需要创建一个 Oauth 提供程序。是否有适用于 Rails 3 的工作宝石或有关该问题的教程?

UPDATE

更新

I know Rails are REST based so I find it very strange that there are no tutorials on how to create a public API and secure it. Does anyone know of any good tutorials. Preferable with oAuth.

我知道 Rails 是基于 REST 的,所以我觉得很奇怪没有关于如何创建公共 API 并保护它的教程。有谁知道有什么好的教程。最好使用 oAuth。

Thankful for all help!!

感谢大家的帮助!!

采纳答案by Andrea Reginato

I've opensourced an OAuth2 server implementationyesterday.

我昨天开源了一个OAuth2 服务器实现

It's well documented and there is a dashboard to control accesses. Right now I'm searching for somebody who wants to build an engine starting from it, or something cool on top of rack. That's why it is open-source.

它有据可查,并且有一个控制访问的仪表板。现在我正在寻找想要从它开始构建引擎的人,或者在机架顶部的一些很酷的东西。这就是为什么它是开源的。

回答by Felipe Philipp

Check out this gem https://github.com/applicake/doorkeeper

看看这个宝石https://github.com/applicake/doorkeeper

It is for Rails 3, the development it's early stages though.

它适用于 Rails 3,但它的开发还处于早期阶段。

There's also an example app that you take a look and see how the API is done.

还有一个示例应用程序,您可以查看并了解 API 是如何完成的。

http://doorkeeper-provider.herokuapp.com/

http://doorkeeper-provider.herokuapp.com/

回答by raidfive

https://github.com/intridea/oauth2is the canonical gem right now for OAuth2 dev. If you are looking for a more complete solution, instead of rolling your own provider code, check out:

https://github.com/intridea/oauth2现在是 OAuth2 开发人员的规范宝石。如果您正在寻找更完整的解决方案,而不是滚动您自己的提供程序代码,请查看:

But I suggest messing around with the oauth2 gem if you aren't very familiar with the flow so that you can learn it better.

但是,如果您不太熟悉流程,我建议您使用 oauth2 gem,以便您可以更好地学习它。

回答by kiwnix

If you are using (or planning to use) devise for authentication, you can use https://github.com/socialcast/devise_oauth2_providableas plugin.

如果您正在使用(或计划使用)设备进行身份验证,您可以使用https://github.com/socialcast/devise_oauth2_providable作为插件。

回答by nov matake

I'm developing a rugygem for OAuth2 provider, Rack::OAuth2. https://github.com/nov/rack-oauth2

我正在为 OAuth2 提供程序 Rack::OAuth2 开发 rugygem。 https://github.com/nov/rack-oauth2

It requires to develop models (token, code, client etc) by yourself, but you can get a whole Rails3 sample OAuth2 server here. https://github.com/nov/rack-oauth2-sample

它需要自己开发模型(令牌、代码、客户端等),但您可以在此处获取完整的 Rails3 示例 OAuth2 服务器。 https://github.com/nov/rack-oauth2-sample

回答by paulomuggler

I'm looking to implement an OAuth2 provider, too! I'm currently experimenting with this https://github.com/assaf/rack-oauth2-server, which seems to be a full-featured OAuth2 server, though it still supports only MongoDB, although implementing support for other DBMS seems simple enough. I am also looking at some of the other options posted here, lots of promising stuff!

我也在寻找实现 OAuth2 提供程序!我目前正在试验这个https://github.com/assaf/rack-oauth2-server,它似乎是一个功能齐全的 OAuth2 服务器,虽然它仍然只支持 MongoDB,但实现对其他 DBMS 的支持似乎很简单. 我也在看这里发布的其他一些选项,很多有前途的东西!

回答by d0minikk

"Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider functionality to your application."

“Doorkeeper 是一款可以轻松将 OAuth 2 提供程序功能引入您的应用程序的宝石。”

https://github.com/applicake/doorkeeper

https://github.com/applicake/doorkeeper