Не найдено ни одного маршрута [GET] "/ oauth / Applications" - PullRequest
0 голосов
/ 12 декабря 2018

Когда я пытаюсь перейти к / oauth / Applications

Я получил 404

Я не вижу маршрут, когда я делаю:

рельсовые маршруты|grep oauth

Я хочу получить 200 и получить доступ к странице.

Моя конфигурация:

# frozen_string_literal: true

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
    User.find_by(id: session[:current_user_id]) || redirect_to(new_user_session_url)
  end

  # In this flow, a token is requested in exchange for the resource owner credentials (username and password)
  resource_owner_from_credentials do |_routes|
    user = User.where(login: params[:username]).first
    if user.valid_password?(params[:password])
      user
    end
  end

  # Access token expiration time (default 2 hours).
  # If you want to disable expiration, set this to nil.
  access_token_expires_in 1.day

  # implicit and password grant flows have risks that you should understand
  # before enabling:
  #   http://tools.ietf.org/html/rfc6819#section-4.4.2
  #   http://tools.ietf.org/html/rfc6819#section-4.4.3
  #
  grant_flows %w(password authorization_code client_credentials)
  # grant_flows %w[password]

  # Under some circumstances you might want to have applications auto-approved,
  # so that the user skips the authorization step.
  # For example if dealing with a trusted application.
  # skip_authorization do |resource_owner, client|
  #   client.superapp? or resource_owner.admin?
  # end
  skip_authorization do
    true
  end

  admin_authenticator do |routes|
    User.find_by(id: session[:admin_id], roles: '{100}') || redirect_to(routes.new_user_session_url)
  end

  # default_scopes :read, :write
  # optional_scopes :create, :update

  # WWW-Authenticate Realm (default "Doorkeeper").
  # realm "Doorkeeper"
end

И в моем файле router.rb:

 use_doorkeeper do
    # No need to register client application
    skip_controllers :applications, :authorized_applications
  end

Ответы [ 3 ]

0 голосов
/ 12 декабря 2018

Вместо

  use_doorkeeper do
    # No need to register client application
    skip_controllers :applications, :authorized_applications
  end

Я использовал:

  use_doorkeeper

Я пропускал контроллер приложений

0 голосов
/ 12 декабря 2018

Вы добавили use_doorkeeper к вашему routes.rb?Он должен выглядеть следующим образом:

Rails.application.routes.draw do
  use_doorkeeper
  # your routes
end

Это смонтирует следующие маршруты:

GET       /oauth/authorize/native?code
GET       /oauth/authorize
POST      /oauth/authorize
DELETE    /oauth/authorize
POST      /oauth/token
POST      /oauth/revoke
POST      /oauth/introspect
resources /oauth/applications
GET       /oauth/authorized_applications
DELETE    /oauth/authorized_applications/:id
GET       /oauth/token/info

Дополнительные сведения о конфигурации маршрутов вы можете найти здесь: https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes

Вы можетеБолее подробную информацию можно найти в официальном README или в Wiki (здесь вы также можете найти некоторые внешние статьи о том, как установить и настроить гем Doorkeeper).

0 голосов
/ 12 декабря 2018

Пожалуйста, добавьте строку ниже в вашем файле route.rb

Rails.application.routes.draw do
  use_doorkeeper
  # your routes
end

Проверьте из документации https://github.com/doorkeeper-gem/doorkeeper#routes

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...