0

ドアキーパー ( https://github.com/applicake/doorkeeper/ ) を使用して単純な OAuth プロバイダーをセットアップしようとしていますが、ルートの名前を変更するのに深刻な問題があります。

事前にロールされている「/oauth」ルートではなく、「/oauth2/v1」としてベース ドアキーパー ルートを設定しようとしています。

wiki ( https://github.com/applicake/doorkeeper/wiki/Customizing-routes ) を読むと、変更するだけでよいようです

Rails.application.routes.draw do
  use_doorkeeper
end

Rails.application.routes.draw do
  use_doorkeeper :scope => 'oauth2/v1'
end

または、名前空間 use_doorkeeper を「oauth2」に変更してから、「v1」のスコープを提供します。残念ながら、何も機能しません。ドアキーパーに他のスコープをまったく使用させることができません。

Railsはroutes.rbでその種の構造を使用しなくなったため、wiki自体はかなり古くなっているようです。そのため、実際に変更しようとしているコードは次のようになります。

DoorkeeperProvider::Application.routes.draw do
  scope 'oauth2' do
    use_doorkeeper :scope => 'v1'
  end
  ...
end

しかし、繰り返しになりますが、スコープを変更できるものは何もないようです。

これは rake ルートの出力です:

      oauth_authorization GET    /oauth2/oauth/authorize(.:format)                   {:action=>"new", :controller=>"doorkeeper/authorizations"}
      oauth_authorization POST   /oauth2/oauth/authorize(.:format)                   {:action=>"create", :controller=>"doorkeeper/authorizations"}
      oauth_authorization DELETE /oauth2/oauth/authorize(.:format)                   {:action=>"destroy", :controller=>"doorkeeper/authorizations"}
              oauth_token POST   /oauth2/oauth/token(.:format)                       {:action=>"create", :controller=>"doorkeeper/tokens"}
       oauth_applications GET    /oauth2/oauth/applications(.:format)                {:action=>"index", :controller=>"doorkeeper/applications"}
                          POST   /oauth2/oauth/applications(.:format)                {:action=>"create", :controller=>"doorkeeper/applications"}
    new_oauth_application GET    /oauth2/oauth/applications/new(.:format)            {:action=>"new", :controller=>"doorkeeper/applications"}
       edit_oauth_application GET    /oauth2/oauth/applications/:id/edit(.:format)       {:action=>"edit", :controller=>"doorkeeper/applications"}
        oauth_application GET    /oauth2/oauth/applications/:id(.:format)            {:action=>"show", :controller=>"doorkeeper/applications"}
                          PUT    /oauth2/oauth/applications/:id(.:format)            {:action=>"update", :controller=>"doorkeeper/applications"}
                          DELETE /oauth2/oauth/applications/:id(.:format)            {:action=>"destroy", :controller=>"doorkeeper/applications"}
oauth_authorized_applications GET    /oauth2/oauth/authorized_applications(.:format)     {:action=>"index", :controller=>"doorkeeper/authorized_applications"}
 oauth_authorized_application DELETE /oauth2/oauth/authorized_applications/:id(.:format) {:action=>"destroy", :controller=>"doorkeeper/authorized_applications"}
         oauth_token_info GET    /oauth2/oauth/token/info(.:format)                  {:action=>"show", :controller=>"doorkeeper/token_info"}

use_doorkeeper の :scope パラメータが無視されているようです。

この時点でのヒントは大歓迎です。

4

1 に答える 1