doorkeeper 2.1.0 → 2.1.1
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/CHANGELOG.md +15 -4
- data/README.md +0 -1
- data/app/controllers/doorkeeper/tokens_controller.rb +5 -1
- data/lib/doorkeeper/config.rb +17 -13
- data/lib/doorkeeper/oauth/authorization/token.rb +16 -5
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +2 -7
- data/lib/doorkeeper/oauth/request_concern.rb +1 -1
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/templates/initializer.rb +6 -6
- data/spec/controllers/tokens_controller_spec.rb +14 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +1 -6
- data/spec/lib/config_spec.rb +0 -6
- data/spec/lib/oauth/authorization_code_request_spec.rb +6 -1
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +10 -33
- data/spec/lib/oauth/password_access_token_request_spec.rb +2 -1
- data/spec/lib/oauth/refresh_token_request_spec.rb +1 -1
- data/spec/lib/oauth/token_request_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4d649c16871a07497bf4fbb26a1eae87d1828a7
|
4
|
+
data.tar.gz: 899cec3d7c504467b362bfdaaa74b7e3b529509a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06ff7fe06ae799a23b2c656573b85f682c2aea2a3c831634d99adc88490cbe261712b3c56ecf6bcaef21ec66cc86d42f503a4ee6b53f2eca155265cf45c13368
|
7
|
+
data.tar.gz: 75f543fcc22b8036a4dab36cc8119ab76b459a9b6a18dcd1442d0eaa400f2ed91074b38b62234743a244cad7cf7163c75e656178caa5a1d7c6757f0d708f2391
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## 2.2.0 (unreleased)
|
4
|
+
|
5
|
+
- Remove `wildcard_redirect_url` option
|
6
|
+
- [#481] Customize token flow OAuth expirations with a config lambda
|
7
|
+
- [#568] TokensController: Memoize strategy.authorize_response result to enable
|
8
|
+
subclasses to use the response object.
|
9
|
+
- [#571] Fix database initialization issues in some configurations.
|
4
10
|
|
5
11
|
|
6
12
|
## 2.1.0
|
@@ -10,19 +16,24 @@
|
|
10
16
|
- [5596227] Check application scopes in AccessToken when present. Fixes a bug in
|
11
17
|
doorkeeper 2.0.0 and 2.0.1 referring to application specific scopes.
|
12
18
|
- [#534] Internationalizes doorkeeper views.
|
13
|
-
- Enable by default `authorization_code` and `client_credentials` grant flows.
|
14
|
-
Disables implicit and password grant flows by default.
|
15
|
-
- [#510, #544, 722113f] Revoked refresh token response bugfix.
|
16
19
|
- [#545] Ensure there is a connection to the database before checking for
|
17
20
|
missing columns
|
18
21
|
- [#546] Use `Doorkeeper::` prefix when referencing `Application` to avoid
|
19
22
|
possible application model name conflict.
|
20
23
|
- [#538] Test with Rails ~> 4.2.
|
21
24
|
|
25
|
+
### Potentially backward incompatible changes
|
26
|
+
|
27
|
+
- Enable by default `authorization_code` and `client_credentials` grant flows.
|
28
|
+
Disables implicit and password grant flows by default.
|
29
|
+
- [#510, #544, 722113f] Revoked refresh token response bugfix.
|
30
|
+
|
31
|
+
|
22
32
|
## 2.0.1
|
23
33
|
|
24
34
|
- [#525, #526, #527] Fix `ActiveRecord::NoDatabaseError` on gem load.
|
25
35
|
|
36
|
+
|
26
37
|
## 2.0.0
|
27
38
|
|
28
39
|
### Backward incompatible changes
|
data/README.md
CHANGED
@@ -25,7 +25,6 @@ https://github.com/doorkeeper-gem/doorkeeper/releases.
|
|
25
25
|
- [Routes](#routes)
|
26
26
|
- [Authenticating](#authenticating)
|
27
27
|
- [Protecting resources with OAuth (a.k.a your API endpoint)](#protecting-resources-with-oauth-aka-your-api-endpoint)
|
28
|
-
- [ActionController::Metal integration](#actioncontrollermetal-integration)
|
29
28
|
- [Route Constraints and other integrations](#route-constraints-and-other-integrations)
|
30
29
|
- [Access Token Scopes](#access-token-scopes)
|
31
30
|
- [Authenticated resource owner](#authenticated-resource-owner)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Doorkeeper
|
2
2
|
class TokensController < Doorkeeper::ApplicationMetalController
|
3
3
|
def create
|
4
|
-
response =
|
4
|
+
response = authorize_response
|
5
5
|
self.headers.merge! response.headers
|
6
6
|
self.response_body = response.body.to_json
|
7
7
|
self.status = response.status
|
@@ -37,5 +37,9 @@ module Doorkeeper
|
|
37
37
|
def strategy
|
38
38
|
@strategy ||= server.token_request params[:grant_type]
|
39
39
|
end
|
40
|
+
|
41
|
+
def authorize_response
|
42
|
+
@authorize_response ||= strategy.authorize
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
data/lib/doorkeeper/config.rb
CHANGED
@@ -19,6 +19,9 @@ module Doorkeeper
|
|
19
19
|
def self.check_for_missing_columns
|
20
20
|
if Doorkeeper.configuration.orm == :active_record &&
|
21
21
|
ActiveRecord::Base.connected? &&
|
22
|
+
ActiveRecord::Base.connection.table_exists?(
|
23
|
+
Doorkeeper::Application.table_name
|
24
|
+
) &&
|
22
25
|
!Doorkeeper::Application.new.attributes.include?("scopes")
|
23
26
|
|
24
27
|
puts <<-MSG.squish
|
@@ -172,28 +175,29 @@ and that your `initialize_models!` method doesn't raise any errors.\n
|
|
172
175
|
|
173
176
|
option :resource_owner_authenticator,
|
174
177
|
as: :authenticate_resource_owner,
|
175
|
-
default: (lambda do |
|
178
|
+
default: (lambda do |_routes|
|
176
179
|
logger.warn(I18n.translate('doorkeeper.errors.messages.resource_owner_authenticator_not_configured'))
|
177
180
|
nil
|
178
181
|
end)
|
179
182
|
option :admin_authenticator,
|
180
183
|
as: :authenticate_admin,
|
181
|
-
default: ->(
|
184
|
+
default: ->(_routes) {}
|
182
185
|
option :resource_owner_from_credentials,
|
183
|
-
default: (lambda do |
|
186
|
+
default: (lambda do |_routes|
|
184
187
|
warn(I18n.translate('doorkeeper.errors.messages.credential_flow_not_configured'))
|
185
188
|
nil
|
186
189
|
end)
|
187
|
-
|
188
|
-
option :
|
189
|
-
option :
|
190
|
-
option :
|
191
|
-
option :
|
192
|
-
option :
|
193
|
-
option :
|
194
|
-
option :
|
195
|
-
option :
|
196
|
-
option :
|
190
|
+
|
191
|
+
option :skip_authorization, default: ->(_routes) {}
|
192
|
+
option :access_token_expires_in, default: 7200
|
193
|
+
option :custom_access_token_expires_in, default: lambda { |_app| nil }
|
194
|
+
option :authorization_code_expires_in, default: 600
|
195
|
+
option :orm, default: :active_record
|
196
|
+
option :native_redirect_uri, default: 'urn:ietf:wg:oauth:2.0:oob'
|
197
|
+
option :active_record_options, default: {}
|
198
|
+
option :realm, default: 'Doorkeeper'
|
199
|
+
option :force_ssl_in_redirect_uri, default: !Rails.env.development?
|
200
|
+
option :grant_flows, default: %w(authorization_code client_credentials)
|
197
201
|
|
198
202
|
attr_reader :reuse_access_token
|
199
203
|
|
@@ -9,13 +9,24 @@ module Doorkeeper
|
|
9
9
|
@resource_owner = resource_owner
|
10
10
|
end
|
11
11
|
|
12
|
+
def self.access_token_expires_in(server, pre_auth)
|
13
|
+
custom_expiration = server.
|
14
|
+
custom_access_token_expires_in.call(pre_auth)
|
15
|
+
|
16
|
+
if custom_expiration
|
17
|
+
custom_expiration
|
18
|
+
else
|
19
|
+
server.access_token_expires_in
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
12
23
|
def issue_token
|
13
24
|
@token ||= AccessToken.find_or_create_for(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
25
|
+
pre_auth.client,
|
26
|
+
resource_owner.id,
|
27
|
+
pre_auth.scopes,
|
28
|
+
self.class.access_token_expires_in(configuration, pre_auth),
|
29
|
+
false
|
19
30
|
)
|
20
31
|
end
|
21
32
|
|
@@ -11,13 +11,8 @@ module Doorkeeper
|
|
11
11
|
|
12
12
|
def self.matches?(url, client_url)
|
13
13
|
url, client_url = as_uri(url), as_uri(client_url)
|
14
|
-
|
15
|
-
|
16
|
-
false
|
17
|
-
else
|
18
|
-
url.query = nil
|
19
|
-
url == client_url
|
20
|
-
end
|
14
|
+
url.query = nil
|
15
|
+
url == client_url
|
21
16
|
end
|
22
17
|
|
23
18
|
def self.valid_for_authorization?(url, client_url)
|
data/lib/doorkeeper/version.rb
CHANGED
@@ -26,6 +26,11 @@ Doorkeeper.configure do
|
|
26
26
|
# If you want to disable expiration, set this to nil.
|
27
27
|
# access_token_expires_in 2.hours
|
28
28
|
|
29
|
+
# Assign a custom TTL for implicit grants.
|
30
|
+
# custom_access_token_expires_in do |oauth_client|
|
31
|
+
# oauth_client.application.additional_settings.implicit_oauth_expiration
|
32
|
+
# end
|
33
|
+
|
29
34
|
# Reuse access token for the same resource owner within an application (disabled by default)
|
30
35
|
# Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
|
31
36
|
# reuse_access_token
|
@@ -90,16 +95,11 @@ Doorkeeper.configure do
|
|
90
95
|
|
91
96
|
# Under some circumstances you might want to have applications auto-approved,
|
92
97
|
# so that the user skips the authorization step.
|
93
|
-
# For example if dealing with trusted
|
98
|
+
# For example if dealing with a trusted application.
|
94
99
|
# skip_authorization do |resource_owner, client|
|
95
100
|
# client.superapp? or resource_owner.admin?
|
96
101
|
# end
|
97
102
|
|
98
103
|
# WWW-Authenticate Realm (default "Doorkeeper").
|
99
104
|
# realm "Doorkeeper"
|
100
|
-
|
101
|
-
# Allow dynamic query parameters (disabled by default)
|
102
|
-
# Some applications require dynamic query parameters on their request_uri
|
103
|
-
# set to true if you want this to be allowed
|
104
|
-
# wildcard_redirect_uri false
|
105
105
|
end
|
@@ -40,4 +40,18 @@ describe Doorkeeper::TokensController do
|
|
40
40
|
expect(response.status).to eq 200
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
describe 'authorize response memoization' do
|
45
|
+
it "memoizes the result of the authorization" do
|
46
|
+
strategy = double(:strategy, authorize: true)
|
47
|
+
expect(strategy).to receive(:authorize).once
|
48
|
+
allow(controller).to receive(:strategy) { strategy }
|
49
|
+
|
50
|
+
controller.stub(:create) do
|
51
|
+
controller.send :authorize_response
|
52
|
+
controller.send :authorize_response
|
53
|
+
end
|
54
|
+
post :create
|
55
|
+
end
|
56
|
+
end
|
43
57
|
end
|
@@ -88,16 +88,11 @@ Doorkeeper.configure do
|
|
88
88
|
|
89
89
|
# Under some circumstances you might want to have applications auto-approved,
|
90
90
|
# so that the user skips the authorization step.
|
91
|
-
# For example if dealing with trusted
|
91
|
+
# For example if dealing with a trusted application.
|
92
92
|
# skip_authorization do |resource_owner, client|
|
93
93
|
# client.superapp? or resource_owner.admin?
|
94
94
|
# end
|
95
95
|
|
96
96
|
# WWW-Authenticate Realm (default "Doorkeeper").
|
97
97
|
realm "Doorkeeper"
|
98
|
-
|
99
|
-
# Allow dynamic query parameters (disabled by default)
|
100
|
-
# Some applications require dynamic query parameters on their request_uri
|
101
|
-
# set to true if you want this to be allowed
|
102
|
-
# wildcard_redirect_uri false
|
103
98
|
end
|
data/spec/lib/config_spec.rb
CHANGED
@@ -199,12 +199,6 @@ describe Doorkeeper, 'configuration' do
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
-
describe 'wildcard_redirect_uri' do
|
203
|
-
it 'is disabled by default' do
|
204
|
-
Doorkeeper.configuration.wildcard_redirect_uri.should be_falsey
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
202
|
describe 'realm' do
|
209
203
|
it 'is \'Doorkeeper\' by default' do
|
210
204
|
expect(Doorkeeper.configuration.realm).to eq('Doorkeeper')
|
@@ -2,7 +2,12 @@ require 'spec_helper_integration'
|
|
2
2
|
|
3
3
|
module Doorkeeper::OAuth
|
4
4
|
describe AuthorizationCodeRequest do
|
5
|
-
let(:server)
|
5
|
+
let(:server) do
|
6
|
+
double :server,
|
7
|
+
access_token_expires_in: 2.days,
|
8
|
+
refresh_token_enabled?: false,
|
9
|
+
custom_access_token_expires_in: ->(_app) { nil }
|
10
|
+
end
|
6
11
|
let(:grant) { FactoryGirl.create :access_grant }
|
7
12
|
let(:client) { grant.application }
|
8
13
|
|
@@ -53,28 +53,16 @@ module Doorkeeper::OAuth::Helpers
|
|
53
53
|
expect(URIChecker.matches?(uri, client_uri)).to be_truthy
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
it 'doesn\'t allow non-matching domains through' do
|
68
|
-
uri = 'http://app.abc/?query=hello'
|
69
|
-
client_uri = 'http://app.co'
|
70
|
-
expect(URIChecker.matches?(uri, client_uri)).to be false
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'doesn\'t allow non-matching domains that don\'t start at the beginning' do
|
74
|
-
uri = 'http://app.co/?query=hello'
|
75
|
-
client_uri = 'http://example.com?app.co=test'
|
76
|
-
expect(URIChecker.matches?(uri, client_uri)).to be false
|
77
|
-
end
|
56
|
+
it 'doesn\'t allow non-matching domains through' do
|
57
|
+
uri = 'http://app.abc/?query=hello'
|
58
|
+
client_uri = 'http://app.co'
|
59
|
+
expect(URIChecker.matches?(uri, client_uri)).to be_falsey
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'doesn\'t allow non-matching domains that don\'t start at the beginning' do
|
63
|
+
uri = 'http://app.co/?query=hello'
|
64
|
+
client_uri = 'http://example.com?app.co=test'
|
65
|
+
expect(URIChecker.matches?(uri, client_uri)).to be_falsey
|
78
66
|
end
|
79
67
|
end
|
80
68
|
|
@@ -111,17 +99,6 @@ module Doorkeeper::OAuth::Helpers
|
|
111
99
|
uri = client_uri = 'http://app.co/aaa?waffles=abc'
|
112
100
|
expect(URIChecker.valid_for_authorization?(uri, client_uri)).to be false
|
113
101
|
end
|
114
|
-
|
115
|
-
context 'allows wildcard redirect_uri' do
|
116
|
-
before do
|
117
|
-
Doorkeeper.configuration.stub(wildcard_redirect_uri: true)
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'is true if valid, matches and contains a query parameter' do
|
121
|
-
uri = client_uri = 'http://app.co/aaa?waffles=abc'
|
122
|
-
expect(URIChecker.valid_for_authorization?(uri, client_uri)).to be true
|
123
|
-
end
|
124
|
-
end
|
125
102
|
end
|
126
103
|
end
|
127
104
|
end
|
@@ -7,7 +7,8 @@ module Doorkeeper::OAuth
|
|
7
7
|
:server,
|
8
8
|
default_scopes: Doorkeeper::OAuth::Scopes.new,
|
9
9
|
access_token_expires_in: 2.hours,
|
10
|
-
refresh_token_enabled?: false
|
10
|
+
refresh_token_enabled?: false,
|
11
|
+
custom_access_token_expires_in: ->(_app) { nil }
|
11
12
|
)
|
12
13
|
end
|
13
14
|
let(:credentials) { Client::Credentials.new(client.uid, client.secret) }
|
@@ -16,7 +16,7 @@ module Doorkeeper::OAuth
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'revokes the previous token' do
|
19
|
-
expect { subject.authorize }
|
19
|
+
expect { subject.authorize }.to change { refresh_token.revoked? }.from(false).to(true)
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'requires the refresh token' do
|
@@ -48,6 +48,23 @@ module Doorkeeper::OAuth
|
|
48
48
|
expect(subject.authorize).to be_a(ErrorResponse)
|
49
49
|
end
|
50
50
|
|
51
|
+
context 'with custom expirations' do
|
52
|
+
before do
|
53
|
+
Doorkeeper.configure do
|
54
|
+
orm DOORKEEPER_ORM
|
55
|
+
custom_access_token_expires_in do |_oauth_client|
|
56
|
+
1234
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should use the custom ttl' do
|
62
|
+
subject.authorize
|
63
|
+
token = Doorkeeper::AccessToken.first
|
64
|
+
expect(token.expires_in).to eq(1234)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
51
68
|
context 'token reuse' do
|
52
69
|
it 'creates a new token if there are no matching tokens' do
|
53
70
|
Doorkeeper.configuration.stub(:reuse_access_token).and_return(true)
|
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: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Elias Philipp
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|