doorkeeper 5.2.0.rc3 → 5.2.0
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/Appraisals +1 -1
- data/CHANGELOG.md +6 -1
- data/Gemfile +1 -1
- data/app/controllers/doorkeeper/application_controller.rb +1 -1
- data/app/controllers/doorkeeper/application_metal_controller.rb +2 -1
- data/gemfiles/rails_6_0.gemfile +1 -1
- data/lib/doorkeeper/config.rb +14 -1
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/templates/initializer.rb +21 -20
- data/spec/lib/config_spec.rb +17 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5184a79d20bb22a118af7f53e465f3d16b4e8796819bc3d3787118b65e2faa5
|
4
|
+
data.tar.gz: 36dbd460edaad12e3550210d3edfa1c2f6b82bfa600c7a6fc3c1e730bc7d34c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b1183b93495fcaf34b7d1761d1e605e9203bdcfa483ebc6b3c11895b781ace879439f84d92d05dc9321bf28014b64e4c2a63666a20a389b26a34f1a5dc3c048
|
7
|
+
data.tar.gz: 75959d91b24d5a34538e9bf2d5fca263bbd9338a1cf20d808a6737b0ec4ee507f2d07ee47031d09ab7211e62be5803223f2a28d4099e91008741606162c3dafa
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,7 +7,12 @@ User-visible changes worth mentioning.
|
|
7
7
|
|
8
8
|
## master
|
9
9
|
|
10
|
-
- [#PR ID]
|
10
|
+
- [#PR ID] Your PR description here.
|
11
|
+
|
12
|
+
## 5.2.0
|
13
|
+
|
14
|
+
- [#1305] Make `Doorkeeper::ApplicationController` to inherit from `ActionController::API` in cases
|
15
|
+
when `api_mode` enabled (fixes #1302).
|
11
16
|
|
12
17
|
## 5.2.0.rc3
|
13
18
|
|
data/Gemfile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Doorkeeper
|
4
|
-
class ApplicationMetalController <
|
4
|
+
class ApplicationMetalController <
|
5
|
+
Doorkeeper.configuration.resolve_controller(:base_metal)
|
5
6
|
include Helpers::Controller
|
6
7
|
|
7
8
|
before_action :enforce_content_type,
|
data/gemfiles/rails_6_0.gemfile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "rails", "~> 6.0.0
|
5
|
+
gem "rails", "~> 6.0.0"
|
6
6
|
gem "rspec-core", git: "https://github.com/rspec/rspec-core.git"
|
7
7
|
gem "rspec-expectations", git: "https://github.com/rspec/rspec-expectations.git"
|
8
8
|
gem "rspec-mocks", git: "https://github.com/rspec/rspec-mocks.git"
|
data/lib/doorkeeper/config.rb
CHANGED
@@ -336,7 +336,9 @@ module Doorkeeper
|
|
336
336
|
#
|
337
337
|
# @param base_controller [String] the name of the base controller
|
338
338
|
option :base_controller,
|
339
|
-
default:
|
339
|
+
default: (lambda do
|
340
|
+
api_only ? "ActionController::API" : "ActionController::Base"
|
341
|
+
end)
|
340
342
|
|
341
343
|
# The controller Doorkeeper::ApplicationMetalController inherits from.
|
342
344
|
# Defaults to ActionController::API.
|
@@ -417,6 +419,17 @@ module Doorkeeper
|
|
417
419
|
@token_reuse_limit ||= 100
|
418
420
|
end
|
419
421
|
|
422
|
+
def resolve_controller(name)
|
423
|
+
config_option = public_send(:"#{name}_controller")
|
424
|
+
controller_name = if config_option.respond_to?(:call)
|
425
|
+
instance_exec(&config_option)
|
426
|
+
else
|
427
|
+
config_option
|
428
|
+
end
|
429
|
+
|
430
|
+
controller_name.constantize
|
431
|
+
end
|
432
|
+
|
420
433
|
def enforce_configured_scopes?
|
421
434
|
option_set? :enforce_configured_scopes
|
422
435
|
end
|
data/lib/doorkeeper/version.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Doorkeeper.configure do
|
4
|
-
# Change the ORM that doorkeeper will use (
|
4
|
+
# Change the ORM that doorkeeper will use (requires ORM extensions installed).
|
5
|
+
# Check the list of supported ORMs here: https://github.com/doorkeeper-gem/doorkeeper#orms
|
5
6
|
orm :active_record
|
6
7
|
|
7
8
|
# This block will be called to check whether the resource owner is authenticated or not.
|
@@ -39,18 +40,18 @@ Doorkeeper.configure do
|
|
39
40
|
#
|
40
41
|
# enforce_content_type
|
41
42
|
|
42
|
-
# Authorization Code expiration time (default 10 minutes).
|
43
|
+
# Authorization Code expiration time (default: 10 minutes).
|
43
44
|
#
|
44
45
|
# authorization_code_expires_in 10.minutes
|
45
46
|
|
46
|
-
# Access token expiration time (default 2 hours).
|
47
|
-
# If you want to disable expiration, set this to nil
|
47
|
+
# Access token expiration time (default: 2 hours).
|
48
|
+
# If you want to disable expiration, set this to `nil`.
|
48
49
|
#
|
49
50
|
# access_token_expires_in 2.hours
|
50
51
|
|
51
52
|
# Assign custom TTL for access tokens. Will be used instead of access_token_expires_in
|
52
53
|
# option if defined. In case the block returns `nil` value Doorkeeper fallbacks to
|
53
|
-
#
|
54
|
+
# +access_token_expires_in+ configuration option value. If you really need to issue a
|
54
55
|
# non-expiring access token (which is not recommended) then you need to return
|
55
56
|
# Float::INFINITY from this block.
|
56
57
|
#
|
@@ -69,8 +70,9 @@ Doorkeeper.configure do
|
|
69
70
|
#
|
70
71
|
# access_token_generator '::Doorkeeper::JWT'
|
71
72
|
|
72
|
-
# The controller Doorkeeper::ApplicationController inherits from.
|
73
|
-
# Defaults to ActionController::Base
|
73
|
+
# The controller +Doorkeeper::ApplicationController+ inherits from.
|
74
|
+
# Defaults to +ActionController::Base+ unless +api_only+ is set, which changes the default to
|
75
|
+
# +ActionController::API+. The return value of this option must be a stringified class name.
|
74
76
|
# See https://doorkeeper.gitbook.io/guides/configuration/other-configurations#custom-base-controller
|
75
77
|
#
|
76
78
|
# base_controller 'ApplicationController'
|
@@ -128,11 +130,10 @@ Doorkeeper.configure do
|
|
128
130
|
#
|
129
131
|
# hash_application_secrets using: '::Doorkeeper::SecretStoring::BCrypt'
|
130
132
|
|
131
|
-
# When the above option is enabled,
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
# you will probably want to enable the fallback to plain tokens.
|
133
|
+
# When the above option is enabled, and a hashed token or secret is not found,
|
134
|
+
# you can allow to fall back to another strategy. For users upgrading
|
135
|
+
# doorkeeper and wishing to enable hashing, you will probably want to enable
|
136
|
+
# the fallback to plain tokens.
|
136
137
|
#
|
137
138
|
# This will ensure that old access tokens and secrets
|
138
139
|
# will remain valid even if the hashing above is enabled.
|
@@ -141,8 +142,8 @@ Doorkeeper.configure do
|
|
141
142
|
|
142
143
|
# Issue access tokens with refresh token (disabled by default), you may also
|
143
144
|
# pass a block which accepts `context` to customize when to give a refresh
|
144
|
-
# token or not. Similar to
|
145
|
-
# the properties:
|
145
|
+
# token or not. Similar to +custom_access_token_expires_in+, `context` has
|
146
|
+
# the following properties:
|
146
147
|
#
|
147
148
|
# `client` - the OAuth client application (see Doorkeeper::OAuth::Client)
|
148
149
|
# `grant_type` - the grant type of the request (see Doorkeeper::OAuth)
|
@@ -151,7 +152,7 @@ Doorkeeper.configure do
|
|
151
152
|
# use_refresh_token
|
152
153
|
|
153
154
|
# Provide support for an owner to be assigned to each registered application (disabled by default)
|
154
|
-
# Optional parameter confirmation: true (default false) if you want to enforce ownership of
|
155
|
+
# Optional parameter confirmation: true (default: false) if you want to enforce ownership of
|
155
156
|
# a registered application
|
156
157
|
# NOTE: you must also run the rails g doorkeeper:application_owner generator
|
157
158
|
# to provide the necessary support
|
@@ -165,17 +166,17 @@ Doorkeeper.configure do
|
|
165
166
|
# default_scopes :public
|
166
167
|
# optional_scopes :write, :update
|
167
168
|
|
168
|
-
#
|
169
|
+
# Allows to restrict only certain scopes for grant_type.
|
169
170
|
# By default, all the scopes will be available for all the grant types.
|
170
171
|
#
|
171
172
|
# Keys to this hash should be the name of grant_type and
|
172
173
|
# values should be the array of scopes for that grant type.
|
173
|
-
# Note: scopes should be from configured_scopes(i.e. default or optional)
|
174
|
+
# Note: scopes should be from configured_scopes (i.e. default or optional)
|
174
175
|
#
|
175
176
|
# scopes_by_grant_type password: [:write], client_credentials: [:update]
|
176
177
|
|
177
178
|
# Forbids creating/updating applications with arbitrary scopes that are
|
178
|
-
# not in configuration, i.e.
|
179
|
+
# not in configuration, i.e. +default_scopes+ or +optional_scopes+.
|
179
180
|
# (disabled by default)
|
180
181
|
#
|
181
182
|
# enforce_configured_scopes
|
@@ -237,7 +238,7 @@ Doorkeeper.configure do
|
|
237
238
|
# is invalid, expired, revoked or has invalid scopes.
|
238
239
|
#
|
239
240
|
# If you want to render error response yourself (i.e. rescue exceptions),
|
240
|
-
# set
|
241
|
+
# set +handle_auth_errors+ to `:raise` and rescue Doorkeeper::Errors::InvalidToken
|
241
242
|
# or following specific errors:
|
242
243
|
#
|
243
244
|
# Doorkeeper::Errors::TokenForbidden, Doorkeeper::Errors::TokenExpired,
|
@@ -399,7 +400,7 @@ Doorkeeper.configure do
|
|
399
400
|
# If you need to block the request at all, then configure your routes.rb or web-server
|
400
401
|
# like nginx to forbid the request.
|
401
402
|
|
402
|
-
# WWW-Authenticate Realm (default "Doorkeeper").
|
403
|
+
# WWW-Authenticate Realm (default: "Doorkeeper").
|
403
404
|
#
|
404
405
|
# realm "Doorkeeper"
|
405
406
|
end
|
data/spec/lib/config_spec.rb
CHANGED
@@ -502,7 +502,21 @@ describe Doorkeeper, "configuration" do
|
|
502
502
|
|
503
503
|
describe "base_controller" do
|
504
504
|
context "default" do
|
505
|
-
it { expect(Doorkeeper.configuration.base_controller).to
|
505
|
+
it { expect(Doorkeeper.configuration.base_controller).to be_an_instance_of(Proc) }
|
506
|
+
|
507
|
+
it "resolves to a ApplicationController::Base in default mode" do
|
508
|
+
expect(Doorkeeper.configuration.resolve_controller(:base))
|
509
|
+
.to eq(ActionController::Base)
|
510
|
+
end
|
511
|
+
|
512
|
+
it "resolves to a ApplicationController::API in api_only mode" do
|
513
|
+
Doorkeeper.configure do
|
514
|
+
api_only
|
515
|
+
end
|
516
|
+
|
517
|
+
expect(Doorkeeper.configuration.resolve_controller(:base))
|
518
|
+
.to eq(ActionController::API)
|
519
|
+
end
|
506
520
|
end
|
507
521
|
|
508
522
|
context "custom" do
|
@@ -526,11 +540,11 @@ describe Doorkeeper, "configuration" do
|
|
526
540
|
before do
|
527
541
|
Doorkeeper.configure do
|
528
542
|
orm DOORKEEPER_ORM
|
529
|
-
base_metal_controller "ApplicationController"
|
543
|
+
base_metal_controller { "ApplicationController" }
|
530
544
|
end
|
531
545
|
end
|
532
546
|
|
533
|
-
it { expect(Doorkeeper.configuration.
|
547
|
+
it { expect(Doorkeeper.configuration.resolve_controller(:base_metal)).to eq(ApplicationController) }
|
534
548
|
end
|
535
549
|
end
|
536
550
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.0
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Elias Philipp
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-
|
14
|
+
date: 2019-09-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: railties
|
@@ -472,9 +472,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
472
472
|
version: '2.4'
|
473
473
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
474
474
|
requirements:
|
475
|
-
- - "
|
475
|
+
- - ">="
|
476
476
|
- !ruby/object:Gem::Version
|
477
|
-
version:
|
477
|
+
version: '0'
|
478
478
|
requirements: []
|
479
479
|
rubygems_version: 3.0.2
|
480
480
|
signing_key:
|