如何将Devise的Rails应用程序转换为OAuth提供程序? [英] How to turn a Rails app with Devise into an OAuth provider?

查看:123
本文介绍了如何将Devise的Rails应用程序转换为OAuth提供程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails应用程序与管理帐户使用Devise进行身份验证。我正在创建第二个应用程序,并希望使用第一个应用程序进行身份验证,而不是在第二个应用程序中复制管理员帐户。所以我的想法是将第一个应用程序转换为OAuth提供程序,以便第二个应用程序可以简单地作为OAuth客户端使用像OmniAuth这样的东西。你以前做过吗?有没有一个插件增加了Devise能够充当OAuth提供商的能力?

I have a Rails application with admin accounts using Devise for authentication. I am creating a second application and would like to authenticate using the first application instead of duplicating admin accounts in the second application. So my idea is to turn the first application into an OAuth provider so that the second app can simply act as an OAuth client using something like OmniAuth. Have you done this before? Is there a plugin which adds the ability to Devise to be able to act as an OAuth provider? What do I need to change/add in order to turn the app into an OAuth provider?

推荐答案

使用 Doorkeeper 宝石。它很容易为您的应用程序引入OAuth 2提供程序功能。它也可以与Devise集成。

Use Doorkeeper gem. Its easy to introduce OAuth 2 provider functionality to your application. It can be also integrated with Devise.

Doorkeeper还提供自动批准并跳过授权步骤的配置选项。在使用一组受信任的应用程序时,这是非常有用的,因此您不要让他们授权您公司的信任应用程序来混淆用户。

Doorkeeper also provides a configuration option to auto-approve and skip the authorization step. This is useful when working with a set of trusted applications, so that you don't confuse your users by requiring them to "authorize" your company's trusted app.

# in config/initializers/doorkeeper.rb
Doorkeeper.configure do
  # ...other config options...

  skip_authorization do
    true
  end

end

这篇关于如何将Devise的Rails应用程序转换为OAuth提供程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆