How to turn a Rails app with Devise into an OAuth provider?

馋奶兔 提交于 2019-12-04 18:05:26

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/25878009/how-to-turn-a-rails-app-with-devise-into-an-oauth-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!