我正在我的应用程序中实现OAuth 2,我已经有了登录/刷新令牌,但我在注销时遇到了一些问题。
我有一组由Doorkeeper生成的路由:
Routes for Doorkeeper::Engine:
authorization GET /authorize(.:format) doorkeeper/authorizations#new
authorization POST /authorize(.:format) doorkeeper/authorizations#cre
我试图使用门卫()来设置一个简单的OAuth提供程序,但是在重命名我的路由时遇到了严重的问题。
我正在尝试将我的基本门卫路径设置为'/oauth2/v1‘,而不是预先滚动的'/oauth’路径。
阅读wiki ()似乎我需要做的就是修改
Rails.application.routes.draw do
use_doorkeeper
end
至
Rails.application.routes.draw do
use_doorkeeper :scope => 'oauth2/v1'
end
或者名称空间use_doorkeeper到'oaut
我很难让看门人用魔法来鉴定.
巫术通过控制器提供了一个登录方法,但是在Doorkeeper.rb文件中使用它并不有效。
Doorkeeper.rb
Doorkeeper.configure do
...
resource_owner_from_credentials do |routes|
login(params[:username], params[:password])
end
给出了这个结果:
NoMethodError (undefined method `login' for #<Doorkeeper::TokensController:0x000
我正在学习如何为rails应用程序开发API。我正在尝试开发它用于移动应用程序。到目前为止,我为大多数控制器开发了一个小api。但是我在登录时遇到了问题。我使用devise进行用户管理,使用rails 4.1。
我观看了实现的铁路广播视频。但在视频中,他们在oauth gem中使用了doorkeeper。我想在没有oauth的情况下实现它。我该怎么做呢?
到目前为止,我添加了doorkeeper gem,并在initialize文件夹中使用以下代码添加了doorkeeper.rb
Doorkeeper.configure do
resource_owner_authenticator do
我正在尝试在我的Rails应用程序中实现doorkeeper。我的应用程序由2个可安装的引擎组成。Api和CoreApi。
constraints :subdomain => 'api' do
mount Api::Engine => '/'
end
constraints :subdomain => 'core.api' do
mount CoreApi::Engine => '/'
end
我想通过OAuth在CoreApi引擎中使用Doorkeeper来保护这些端点。
我在我的ruby on rails应用程序上使用了doorkeeper的OAuth功能。此外,我还使用devise进行用户安全管理。
这是我当前的doorkeeper.rb文件:
Doorkeeper.configure do
orm :active_record
resource_owner_authenticator do
user_signed_in? || redirect_to(new_user_session_url)
end
admin_authenticator do
user_signed_in? || redirect_to(new_us
我在路由文件中有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
我测试了新的Rails5API。我想创建一个由js客户端使用的oauth2服务器。
我使用Doorkeeper来管理oauth2服务器。
在我的routes.rb中
Rails.application.routes.draw do
use_doorkeeper
end
doorkeeper.rb
resource_owner_authenticator do
User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
end
当我转到'‘时,我得到了错误:
ActionView::Templ
doorkeeper.rb
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
fail "Please configure doorkeeper resource_owne
我正在为我的一个Rails应用程序设置和。我的目标是允许用户根据他们的access_token访问api,这样只有用户才能看到他们的'user_show‘json。到目前为止,我已经在“OAuth2/ applications”路线上设置和授权了我的开发和生产应用程序。
我的'/config/initializers/doorkeeper.rb‘
Doorkeeper.configure do
# Change the ORM that doorkeeper will use.
# Currently supported options are :active_reco
有两个名称空间:
api/public
api/mobile
在公共控制器中创建具有适当范围的门卫授权。例如:
class API::Public::PostsController < ApplicationController
before_action -> { doorkeeper_authorize! :public }
def show
@post = Post.find(params[:id])
end
end
移动命名空间中的控制器是从公共命名空间中的控制器继承的。例如:
class API::Mobile::PostsController &l
我有一个新安装的带有MongoMapper的rails 4。现在,我正在尝试在我的rails实例上安装doorkeeper。
我在我的Gemfile中添加了"gem 'doorkeeper-mongodb'“行。然后我运行了'bundle install‘。我得到了以下错误:
Could not find gem 'doorkeeper-mongodb (>= 0) ruby' in any of the gem sources listed in your Gemfile or available on this machine.
此外,
我安装了doorkeeper,并且我没有进行任何配置,也没有在application.css中包含任何doorkeeper的样式表,但是仍然列出了doorkeeper的样式表。
Application.css的内容:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/sty
我用的是守门人宝石
我的ApplicationController是这样的:
private
def current_resource_owner
Person.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
end
我的DemosController是这样的:
doorkeeper_for :index
respond_to :json
def index
respond_with current_resource_owner
end
响应如下:
Started GET "/?code=f88
当我试图从中删除我的一个应用程序时,我收到了下面的错误。
Started DELETE "/api/v1/oauth/applications/5930bd2aa54dd321f7248178" for ::1
at 2017-06-01 21:53:22 -0400
Processing by Doorkeeper::ApplicationsController#destroy as HTML
Parameters: {"utf8"=>"✓",
"authenticity_token"=>"+Ixd
当我在rails应用程序中使用时,我得到了一个奇怪的错误。下面是我的doorkeeper.rb文件的样子:
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 |routes|
按照看门人github自述的指示(我想),我得到了尽可能多的before_action。
class ReadingsController < ApplicationController
before_action :doorkeeper_authorize! # Require access token for all actions
...
end
RubyMine抱怨:doorkeeper_authorize!没有在作用域中定义。不管怎么说,我会得到:
Processing by ReadingsController#index as HTML
Filter chain hal
在回拨process_action回调之前,我收到了错误。
:doorkeeper_authorize! has not been defined
在安装rails admin之后,我开始得到这个错误。
class Api::V1::User::UsersController < Api::ApiApplicationController
skip_before_action :doorkeeper_authorize!, only: %i[create]
def create
user = User.new(user_params)
end
end
我想要覆盖门卫令牌错误响应主体方法。当前,当我在http://localhost:3000/oauth/token网址上传递用户名和密码错误时,它会给出下面的错误消息。
默认的未授权门卫响应:
{
"error": "invalid_grant",
"error_description": "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authori
我正在尝试使用devise (3.4.1) + doorkeeper (2.4.1) + Rails 4.2构建一个api,当我尝试连接我的前端应用程序时,我一直收到错误消息"The Authorization server not support this response type“,下面是来自控制台的转储:
Started GET "/oauth/authorize?response_type=token&client_id=a91f8fea40322739310b0db9ee3e3d53878bff0df073f3aa36af7da4f99b365e&r
我有一个使用devise 4.7.1,doorkeeper 5.5.1和devise-doorkeeper 1.2.0的Rails 6.1应用程序。 我正在尝试运行一个(PKCE) OAuth流,但是最后一步--对/oauth/token的POST请求--返回了一个401未授权的JSON content {"error": "You need to sign in or sign up before continuing."}错误。 我对此感到困惑,因为据我所知,未经身份验证的用户应该可以访问/oauth/token端点。同样奇怪的(但可能是转移注意力的)是,