Чего не хватает в присяге ресурсов привратнику? - PullRequest
0 голосов
/ 22 января 2019

У меня есть use_doorkeeper в файле маршрутов. Когда я посещаю http://localhost:3021/oauth/applications, я получаю:

Access to localhost was denied You don't have authorization to view this page.
HTTP ERROR 403

Я также не могу создать нового клиента в http://localhost:3021/oauth/applications/new.

Чего не хватает?

Это мой файл маршрутов

Rails.application.routes.draw do

  use_doorkeeper

end

А это мой инициализатор dookeeper

Doorkeeper.configure do
  # Change the ORM that doorkeeper will use (needs plugins)
  orm :active_record

  # This block will be called to check whether the resource owner is authenticated or not.
  resource_owner_authenticator do
    #raise "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"
    # Put your resource owner authentication logic here.
    # Example implementation:
    User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
    #current_user || User.authenticate!(:scope => :user)

  end
end

1 Ответ

0 голосов
/ 20 марта 2019

Проверьте вывод журнала в консоли. Если вы видите следующие строки, проблема может быть в вашем doorkeeper.rb

Access to admin panel is forbidden due to Doorkeeper.configure.admin_authenticator being unconfigured.
Filter chain halted as :authenticate_admin! rendered or redirected
Completed 403 Forbidden in 2ms (ActiveRecord: 0.0ms)

Вы должны раскомментировать этот раздел:

  # admin_authenticator do
  #   # Put your admin authentication logic here.
  #   # Example implementation:
  #
  # if current_user
  #  head :forbidden unless current_user.admin?
  #   else
  #     redirect_to sign_in_url
  #   end
  # end

и удалите head :forbidden unless current_user.admin?, если у вас не установлена ​​роль администратора.

А может быть изменить URL перенаправления

...