doorkeeper 4.2.0 → 4.2.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +5 -0
- data/.travis.yml +11 -6
- data/Appraisals +14 -0
- data/Gemfile +4 -8
- data/NEWS.md +10 -1
- data/README.md +6 -1
- data/app/controllers/doorkeeper/applications_controller.rb +1 -5
- data/app/views/doorkeeper/applications/_delete_form.html.erb +1 -2
- data/app/views/doorkeeper/authorized_applications/_delete_form.html.erb +1 -2
- data/config/locales/en.yml +2 -2
- data/doorkeeper.gemspec +9 -7
- data/gemfiles/rails_4_2.gemfile +11 -0
- data/gemfiles/rails_5_0.gemfile +12 -0
- data/gemfiles/rails_5_1.gemfile +13 -0
- data/lib/doorkeeper.rb +7 -1
- data/lib/doorkeeper/config.rb +55 -0
- data/lib/doorkeeper/grape/helpers.rb +2 -1
- data/lib/doorkeeper/helpers/controller.rb +6 -6
- data/lib/doorkeeper/models/access_grant_mixin.rb +12 -0
- data/lib/doorkeeper/models/access_token_mixin.rb +117 -1
- data/lib/doorkeeper/models/application_mixin.rb +18 -2
- data/lib/doorkeeper/models/concerns/accessible.rb +4 -0
- data/lib/doorkeeper/models/concerns/expirable.rb +8 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +18 -0
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +20 -18
- data/lib/doorkeeper/oauth/authorization_code_request.rb +1 -4
- data/lib/doorkeeper/oauth/{request_concern.rb → base_request.rb} +3 -1
- data/lib/doorkeeper/oauth/base_response.rb +29 -0
- data/lib/doorkeeper/oauth/client.rb +0 -1
- data/lib/doorkeeper/oauth/client/credentials.rb +17 -6
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials_request.rb +1 -4
- data/lib/doorkeeper/oauth/code_response.rb +7 -6
- data/lib/doorkeeper/oauth/error_response.rb +9 -8
- data/lib/doorkeeper/oauth/invalid_token_response.rb +2 -0
- data/lib/doorkeeper/oauth/password_access_token_request.rb +1 -3
- data/lib/doorkeeper/oauth/refresh_token_request.rb +3 -7
- data/lib/doorkeeper/oauth/token.rb +17 -19
- data/lib/doorkeeper/oauth/token_request.rb +1 -2
- data/lib/doorkeeper/orm/active_record/access_token.rb +17 -0
- data/lib/doorkeeper/orm/active_record/application.rb +10 -5
- data/lib/doorkeeper/rails/helpers.rb +0 -2
- data/lib/doorkeeper/rails/routes.rb +3 -4
- data/lib/doorkeeper/rails/routes/mapper.rb +3 -3
- data/lib/doorkeeper/rails/routes/mapping.rb +1 -1
- data/lib/doorkeeper/request/authorization_code.rb +7 -1
- data/lib/doorkeeper/request/refresh_token.rb +1 -1
- data/lib/doorkeeper/server.rb +0 -8
- data/lib/doorkeeper/version.rb +1 -1
- data/spec/controllers/authorizations_controller_spec.rb +17 -3
- data/spec/lib/doorkeeper_spec.rb +135 -13
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +1 -2
- data/spec/lib/oauth/base_request_spec.rb +160 -0
- data/spec/lib/oauth/base_response_spec.rb +45 -0
- data/spec/lib/oauth/client/credentials_spec.rb +41 -0
- data/spec/lib/oauth/error_response_spec.rb +9 -9
- data/spec/lib/oauth/invalid_token_response_spec.rb +36 -8
- data/spec/lib/server_spec.rb +0 -3
- data/spec/requests/endpoints/authorization_spec.rb +5 -6
- data/spec/requests/flows/authorization_code_spec.rb +4 -12
- data/spec/spec_helper.rb +2 -0
- data/spec/spec_helper_integration.rb +5 -0
- data/spec/support/helpers/request_spec_helper.rb +12 -4
- data/spec/support/http_method_shim.rb +20 -6
- metadata +43 -21
- data/lib/doorkeeper/oauth/client/methods.rb +0 -18
- data/spec/lib/oauth/client/methods_spec.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 990a2d9feaf3dd9945bac2a76742b719521e12c8
|
4
|
+
data.tar.gz: 6a9e2f52ad07979a02040219f7a1f25c9768e353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 641cb1c261a315bd330719a00ba622dbfd61c973f30124698db92ee33b3ff88314d4636e459fd367b73fffdd49da945307e3947a243bdbaf710f9a76a9c1759f
|
7
|
+
data.tar.gz: cb2ff264f9e2e175bd3ed311d54ea24603d16f36b51bf4cdbb56fe4fe855e3785f668b9f0e8a5692ae85bc8057daaa47f14fde8c7cca367c6f08a6dce97bfb54
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -4,17 +4,22 @@ sudo: false
|
|
4
4
|
|
5
5
|
rvm:
|
6
6
|
- 2.1
|
7
|
-
- 2.2.
|
8
|
-
- 2.3.
|
7
|
+
- 2.2.6
|
8
|
+
- 2.3.3
|
9
9
|
|
10
10
|
before_install:
|
11
11
|
- gem install bundler -v '~> 1.10'
|
12
12
|
|
13
|
-
|
14
|
-
-
|
15
|
-
-
|
13
|
+
gemfile:
|
14
|
+
- gemfiles/rails_4_2.gemfile
|
15
|
+
- gemfiles/rails_5_0.gemfile
|
16
|
+
- gemfiles/rails_5_1.gemfile
|
16
17
|
|
17
18
|
matrix:
|
18
19
|
exclude:
|
19
|
-
-
|
20
|
+
- gemfile: gemfiles/rails_5_0.gemfile
|
20
21
|
rvm: 2.1
|
22
|
+
- gemfile: gemfiles/rails_5_1.gemfile
|
23
|
+
rvm: 2.1
|
24
|
+
allowed_failures:
|
25
|
+
- gemfile: gemfiles/rails_5_1.gemfile
|
data/Appraisals
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
appraise "rails-4-2" do
|
2
|
+
gem "rails", "~> 4.2.0"
|
3
|
+
end
|
4
|
+
|
5
|
+
appraise "rails-5-0" do
|
6
|
+
gem "rails", "~> 5.0.0"
|
7
|
+
gem "rspec-rails", "~> 3.5"
|
8
|
+
end
|
9
|
+
|
10
|
+
appraise "rails-5-1" do
|
11
|
+
gem "rails", github: "rails/rails"
|
12
|
+
gem "arel", github: "rails/arel"
|
13
|
+
gem "rspec-rails", "~> 3.5"
|
14
|
+
end
|
data/Gemfile
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
ENV["rails"] ||= "4.2.0"
|
2
|
-
|
3
1
|
source "https://rubygems.org"
|
4
2
|
|
5
|
-
gem "rails", "~>
|
3
|
+
gem "rails", "~> 4.2.0"
|
6
4
|
|
7
|
-
|
8
|
-
gem "rspec-rails", "3.5.1"
|
9
|
-
end
|
5
|
+
gem "appraisal"
|
10
6
|
|
11
7
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
12
|
-
gem "sqlite3", platform: [:ruby, :mswin, :mingw]
|
13
|
-
|
8
|
+
gem "sqlite3", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
9
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
|
14
10
|
gemspec
|
data/NEWS.md
CHANGED
@@ -2,7 +2,16 @@
|
|
2
2
|
|
3
3
|
User-visible changes worth mentioning.
|
4
4
|
|
5
|
-
##
|
5
|
+
## 4.2.5
|
6
|
+
|
7
|
+
- [#936] Deprecate `Doorkeeper#configured?`, `Doorkeeper#database_installed?`, and
|
8
|
+
`Doorkeeper#installed?`
|
9
|
+
- [#909] Add `InvalidTokenResponse#reason` reader method to allow read the kind
|
10
|
+
of invalid token error.
|
11
|
+
- [#928] Test against more recent Ruby versions
|
12
|
+
- Small refactorings within the codebase
|
13
|
+
- [#921] Switch to Appraisal, and test against Rails master
|
14
|
+
- [#892] Add minimum Ruby version requirement
|
6
15
|
|
7
16
|
## 4.2.0
|
8
17
|
|
data/README.md
CHANGED
@@ -176,7 +176,7 @@ You can pass any option `before_action` accepts, such as `if`, `only`,
|
|
176
176
|
|
177
177
|
### Protect your API with OAuth when using Grape
|
178
178
|
|
179
|
-
As of [PR 567] doorkeeper has helpers for Grape. One of them is
|
179
|
+
As of [PR 567] doorkeeper has helpers for Grape >= 0.10. One of them is
|
180
180
|
`doorkeeper_authorize!` and can be used in a similar way as an example above.
|
181
181
|
Note that you have to use `require 'doorkeeper/grape/helpers'` and
|
182
182
|
`helpers Doorkeeper::Grape::Helpers`.
|
@@ -198,6 +198,11 @@ module API
|
|
198
198
|
doorkeeper_authorize!
|
199
199
|
end
|
200
200
|
|
201
|
+
route_setting :scopes, ['user:email']
|
202
|
+
get :emails do
|
203
|
+
[{'email' => current_user.email}]
|
204
|
+
end
|
205
|
+
|
201
206
|
# ...
|
202
207
|
end
|
203
208
|
end
|
@@ -44,11 +44,7 @@ module Doorkeeper
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def application_params
|
47
|
-
|
48
|
-
params.require(:doorkeeper_application).permit(:name, :redirect_uri, :scopes)
|
49
|
-
else
|
50
|
-
params[:doorkeeper_application].slice(:name, :redirect_uri, :scopes) rescue nil
|
51
|
-
end
|
47
|
+
params.require(:doorkeeper_application).permit(:name, :redirect_uri, :scopes)
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
<%- submit_btn_css ||= 'btn btn-link' %>
|
2
|
-
<%= form_tag oauth_application_path(application) do %>
|
3
|
-
<input type="hidden" name="_method" value="delete">
|
2
|
+
<%= form_tag oauth_application_path(application), method: :delete do %>
|
4
3
|
<%= submit_tag t('doorkeeper.applications.buttons.destroy'), onclick: "return confirm('#{ t('doorkeeper.applications.confirmations.destroy') }')", class: submit_btn_css %>
|
5
4
|
<% end %>
|
@@ -1,5 +1,4 @@
|
|
1
1
|
<%- submit_btn_css ||= 'btn btn-link' %>
|
2
|
-
<%= form_tag oauth_authorized_application_path(application) do %>
|
3
|
-
<input type="hidden" name="_method" value="delete">
|
2
|
+
<%= form_tag oauth_authorized_application_path(application), method: :delete do %>
|
4
3
|
<%= submit_tag t('doorkeeper.authorized_applications.buttons.revoke'), onclick: "return confirm('#{ t('doorkeeper.authorized_applications.confirmations.revoke') }')", class: submit_btn_css %>
|
5
4
|
<% end %>
|
data/config/locales/en.yml
CHANGED
@@ -82,9 +82,9 @@ en:
|
|
82
82
|
server_error: 'The authorization server encountered an unexpected condition which prevented it from fulfilling the request.'
|
83
83
|
temporarily_unavailable: 'The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server.'
|
84
84
|
|
85
|
-
#
|
85
|
+
# Configuration error messages
|
86
86
|
credential_flow_not_configured: 'Resource Owner Password Credentials flow failed due to Doorkeeper.configure.resource_owner_from_credentials being unconfigured.'
|
87
|
-
resource_owner_authenticator_not_configured: 'Resource Owner find failed due to Doorkeeper.configure.resource_owner_authenticator being
|
87
|
+
resource_owner_authenticator_not_configured: 'Resource Owner find failed due to Doorkeeper.configure.resource_owner_authenticator being unconfigured.'
|
88
88
|
|
89
89
|
# Access grant errors
|
90
90
|
unsupported_response_type: 'The authorization server does not support this response type.'
|
data/doorkeeper.gemspec
CHANGED
@@ -5,8 +5,8 @@ require "doorkeeper/version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "doorkeeper"
|
7
7
|
s.version = Doorkeeper::VERSION
|
8
|
-
s.authors = ["Felipe Elias Philipp", "Tute Costa"]
|
9
|
-
s.email = %w(
|
8
|
+
s.authors = ["Felipe Elias Philipp", "Tute Costa", "Jon Moss"]
|
9
|
+
s.email = %w(me@jonathanmoss.me)
|
10
10
|
s.homepage = "https://github.com/doorkeeper-gem/doorkeeper"
|
11
11
|
s.summary = "OAuth 2 provider for Rails and Grape"
|
12
12
|
s.description = "Doorkeeper is an OAuth 2 provider for Rails and Grape."
|
@@ -17,12 +17,14 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
s.add_dependency "railties", ">= 4.2"
|
20
|
+
s.required_ruby_version = ">= 2.1"
|
20
21
|
|
21
22
|
s.add_development_dependency "capybara"
|
22
|
-
s.add_development_dependency "
|
23
|
-
s.add_development_dependency "
|
24
|
-
s.add_development_dependency "
|
25
|
-
s.add_development_dependency "
|
23
|
+
s.add_development_dependency "coveralls"
|
24
|
+
s.add_development_dependency "database_cleaner", "~> 1.5.3"
|
25
|
+
s.add_development_dependency "factory_girl", "~> 4.7.0"
|
26
|
+
s.add_development_dependency "generator_spec", "~> 0.9.3"
|
27
|
+
s.add_development_dependency "rake", ">= 11.3.0"
|
26
28
|
s.add_development_dependency "rspec-rails"
|
27
|
-
s.add_development_dependency "timecop", "~> 0.
|
29
|
+
s.add_development_dependency "timecop", "~> 0.8.1"
|
28
30
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 4.2.0"
|
6
|
+
gem "appraisal"
|
7
|
+
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
8
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw, :x64_mingw]
|
9
|
+
gem "tzinfo-data", :platforms => [:mingw, :mswin, :x64_mingw]
|
10
|
+
|
11
|
+
gemspec :path => "../"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", "~> 5.0.0"
|
6
|
+
gem "appraisal"
|
7
|
+
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
8
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw, :x64_mingw]
|
9
|
+
gem "tzinfo-data", :platforms => [:mingw, :mswin, :x64_mingw]
|
10
|
+
gem "rspec-rails", "~> 3.5"
|
11
|
+
|
12
|
+
gemspec :path => "../"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "rails", :github => "rails/rails"
|
6
|
+
gem "appraisal"
|
7
|
+
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
8
|
+
gem "sqlite3", :platform => [:ruby, :mswin, :mingw, :x64_mingw]
|
9
|
+
gem "tzinfo-data", :platforms => [:mingw, :mswin, :x64_mingw]
|
10
|
+
gem "arel", :github => "rails/arel"
|
11
|
+
gem "rspec-rails", "~> 3.5"
|
12
|
+
|
13
|
+
gemspec :path => "../"
|
data/lib/doorkeeper.rb
CHANGED
@@ -16,11 +16,12 @@ require 'doorkeeper/oauth/helpers/unique_token'
|
|
16
16
|
|
17
17
|
require 'doorkeeper/oauth/scopes'
|
18
18
|
require 'doorkeeper/oauth/error'
|
19
|
+
require 'doorkeeper/oauth/base_response'
|
19
20
|
require 'doorkeeper/oauth/code_response'
|
20
21
|
require 'doorkeeper/oauth/token_response'
|
21
22
|
require 'doorkeeper/oauth/error_response'
|
22
23
|
require 'doorkeeper/oauth/pre_authorization'
|
23
|
-
require 'doorkeeper/oauth/
|
24
|
+
require 'doorkeeper/oauth/base_request'
|
24
25
|
require 'doorkeeper/oauth/authorization_code_request'
|
25
26
|
require 'doorkeeper/oauth/refresh_token_request'
|
26
27
|
require 'doorkeeper/oauth/password_access_token_request'
|
@@ -48,16 +49,21 @@ require 'doorkeeper/rails/helpers'
|
|
48
49
|
|
49
50
|
require 'doorkeeper/orm/active_record'
|
50
51
|
|
52
|
+
require 'active_support/deprecation'
|
53
|
+
|
51
54
|
module Doorkeeper
|
52
55
|
def self.configured?
|
56
|
+
ActiveSupport::Deprecation.warn "Method `Doorkeeper#configured?` has been deprecated without replacement."
|
53
57
|
@config.present?
|
54
58
|
end
|
55
59
|
|
56
60
|
def self.database_installed?
|
61
|
+
ActiveSupport::Deprecation.warn "Method `Doorkeeper#database_installed?` has been deprecated without replacement."
|
57
62
|
[AccessToken, AccessGrant, Application].all?(&:table_exists?)
|
58
63
|
end
|
59
64
|
|
60
65
|
def self.installed?
|
66
|
+
ActiveSupport::Deprecation.warn "Method `Doorkeeper#installed?` has been deprecated without replacement."
|
61
67
|
configured? && database_installed?
|
62
68
|
end
|
63
69
|
|
data/lib/doorkeeper/config.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Doorkeeper
|
2
2
|
class MissingConfiguration < StandardError
|
3
|
+
# Defines a MissingConfiguration error for a missing Doorkeeper
|
4
|
+
# configuration
|
3
5
|
def initialize
|
4
6
|
super('Configuration for doorkeeper missing. Do you have doorkeeper initializer?')
|
5
7
|
end
|
@@ -47,6 +49,15 @@ doorkeeper.
|
|
47
49
|
@config
|
48
50
|
end
|
49
51
|
|
52
|
+
# Provide support for an owner to be assigned to each registered
|
53
|
+
# application (disabled by default)
|
54
|
+
# Optional parameter confirmation: true (default false) if you want
|
55
|
+
# to enforce ownership of a registered application
|
56
|
+
#
|
57
|
+
# @param opts [Hash] the options to confirm if an application owner
|
58
|
+
# is present
|
59
|
+
# @option opts[Boolean] :confirmation (false)
|
60
|
+
# Set confirm_application_owner variable
|
50
61
|
def enable_application_owner(opts = {})
|
51
62
|
@config.instance_variable_set('@enable_application_owner', true)
|
52
63
|
confirm_application_owner if opts[:confirmation].present? && opts[:confirmation]
|
@@ -56,44 +67,88 @@ doorkeeper.
|
|
56
67
|
@config.instance_variable_set('@confirm_application_owner', true)
|
57
68
|
end
|
58
69
|
|
70
|
+
# Define default access token scopes for your provider
|
71
|
+
#
|
72
|
+
# @param scopes [Array] Default set of access (OAuth::Scopes.new)
|
73
|
+
# token scopes
|
59
74
|
def default_scopes(*scopes)
|
60
75
|
@config.instance_variable_set('@default_scopes', OAuth::Scopes.from_array(scopes))
|
61
76
|
end
|
62
77
|
|
78
|
+
# Define default access token scopes for your provider
|
79
|
+
#
|
80
|
+
# @param scopes [Array] Optional set of access (OAuth::Scopes.new)
|
81
|
+
# token scopes
|
63
82
|
def optional_scopes(*scopes)
|
64
83
|
@config.instance_variable_set('@optional_scopes', OAuth::Scopes.from_array(scopes))
|
65
84
|
end
|
66
85
|
|
86
|
+
# Change the way client credentials are retrieved from the request object.
|
87
|
+
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
|
88
|
+
# falls back to the `:client_id` and `:client_secret` params from the
|
89
|
+
# `params` object.
|
90
|
+
#
|
91
|
+
# @param methods [Array] Define client credentials
|
67
92
|
def client_credentials(*methods)
|
68
93
|
@config.instance_variable_set('@client_credentials', methods)
|
69
94
|
end
|
70
95
|
|
96
|
+
# Change the way access token is authenticated from the request object.
|
97
|
+
# By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
|
98
|
+
# falls back to the `:access_token` or `:bearer_token` params from the
|
99
|
+
# `params` object.
|
100
|
+
#
|
101
|
+
# @param methods [Array] Define access token methods
|
71
102
|
def access_token_methods(*methods)
|
72
103
|
@config.instance_variable_set('@access_token_methods', methods)
|
73
104
|
end
|
74
105
|
|
106
|
+
# Issue access tokens with refresh token (disabled by default)
|
75
107
|
def use_refresh_token
|
76
108
|
@config.instance_variable_set('@refresh_token_enabled', true)
|
77
109
|
end
|
78
110
|
|
111
|
+
# WWW-Authenticate Realm (default "Doorkeeper").
|
112
|
+
#
|
113
|
+
# @param realm [String] ("Doorkeeper") Authentication realm
|
79
114
|
def realm(realm)
|
80
115
|
@config.instance_variable_set('@realm', realm)
|
81
116
|
end
|
82
117
|
|
118
|
+
# Reuse access token for the same resource owner within an application
|
119
|
+
# (disabled by default)
|
120
|
+
# Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
|
83
121
|
def reuse_access_token
|
84
122
|
@config.instance_variable_set("@reuse_access_token", true)
|
85
123
|
end
|
86
124
|
|
125
|
+
# Forces the usage of the HTTPS protocol in non-native redirect uris
|
126
|
+
# (enabled by default in non-development environments). OAuth2
|
127
|
+
# delegates security in communication to the HTTPS protocol so it is
|
128
|
+
# wise to keep this enabled.
|
129
|
+
#
|
130
|
+
# @param [Boolean] boolean value for the parameter, true by default in
|
131
|
+
# non-development environment
|
87
132
|
def force_ssl_in_redirect_uri(boolean)
|
88
133
|
@config.instance_variable_set("@force_ssl_in_redirect_uri", boolean)
|
89
134
|
end
|
90
135
|
|
136
|
+
# Use a custom class for generating the access token.
|
137
|
+
# https://github.com/doorkeeper-gem/doorkeeper#custom-access-token-generator
|
138
|
+
#
|
139
|
+
# @param access_token_generator [String]
|
140
|
+
# the name of the access token generator class
|
91
141
|
def access_token_generator(access_token_generator)
|
92
142
|
@config.instance_variable_set(
|
93
143
|
'@access_token_generator', access_token_generator
|
94
144
|
)
|
95
145
|
end
|
96
146
|
|
147
|
+
# The controller Doorkeeper::ApplicationController inherits from.
|
148
|
+
# Defaults to ActionController::Base.
|
149
|
+
# https://github.com/doorkeeper-gem/doorkeeper#custom-base-controller
|
150
|
+
#
|
151
|
+
# @param base_controller [String] the name of the base controller
|
97
152
|
def base_controller(base_controller)
|
98
153
|
@config.instance_variable_set('@base_controller', base_controller)
|
99
154
|
end
|
@@ -3,12 +3,13 @@ require 'doorkeeper/grape/authorization_decorator'
|
|
3
3
|
module Doorkeeper
|
4
4
|
module Grape
|
5
5
|
module Helpers
|
6
|
+
# These helpers are for grape >= 0.10
|
6
7
|
extend ::Grape::API::Helpers
|
7
8
|
include Doorkeeper::Rails::Helpers
|
8
9
|
|
9
10
|
# endpoint specific scopes > parameter scopes > default scopes
|
10
11
|
def doorkeeper_authorize!(*scopes)
|
11
|
-
endpoint_scopes = env[
|
12
|
+
endpoint_scopes = env["api.endpoint"].route_setting(:scopes)
|
12
13
|
scopes = if endpoint_scopes
|
13
14
|
Doorkeeper::OAuth::Scopes.from_array(endpoint_scopes)
|
14
15
|
elsif scopes && !scopes.empty?
|
@@ -1,15 +1,15 @@
|
|
1
|
+
# Define methods that can be called in any controller that inherits from
|
2
|
+
# Doorkeeper::ApplicationMetalController or Doorkeeper::ApplicationController
|
1
3
|
module Doorkeeper
|
2
4
|
module Helpers
|
3
5
|
module Controller
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
6
|
private
|
7
7
|
|
8
|
-
def authenticate_resource_owner!
|
8
|
+
def authenticate_resource_owner! # :doc:
|
9
9
|
current_resource_owner
|
10
10
|
end
|
11
11
|
|
12
|
-
def current_resource_owner
|
12
|
+
def current_resource_owner # :doc:
|
13
13
|
instance_eval(&Doorkeeper.configuration.authenticate_resource_owner)
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,7 @@ module Doorkeeper
|
|
17
17
|
instance_eval(&Doorkeeper.configuration.resource_owner_from_credentials)
|
18
18
|
end
|
19
19
|
|
20
|
-
def authenticate_admin!
|
20
|
+
def authenticate_admin! # :doc:
|
21
21
|
instance_eval(&Doorkeeper.configuration.authenticate_admin)
|
22
22
|
end
|
23
23
|
|
@@ -25,7 +25,7 @@ module Doorkeeper
|
|
25
25
|
@server ||= Server.new(self)
|
26
26
|
end
|
27
27
|
|
28
|
-
def doorkeeper_token
|
28
|
+
def doorkeeper_token # :doc:
|
29
29
|
@token ||= OAuth::Token.authenticate request, *config_methods
|
30
30
|
end
|
31
31
|
|