doorkeeper 2.1.1 → 2.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4d649c16871a07497bf4fbb26a1eae87d1828a7
4
- data.tar.gz: 899cec3d7c504467b362bfdaaa74b7e3b529509a
3
+ metadata.gz: d01017121a759c48e73796768589be94d4b30483
4
+ data.tar.gz: 34ff11b0a073fa7fac25a650e412c1d273e3d035
5
5
  SHA512:
6
- metadata.gz: 06ff7fe06ae799a23b2c656573b85f682c2aea2a3c831634d99adc88490cbe261712b3c56ecf6bcaef21ec66cc86d42f503a4ee6b53f2eca155265cf45c13368
7
- data.tar.gz: 75f543fcc22b8036a4dab36cc8119ab76b459a9b6a18dcd1442d0eaa400f2ed91074b38b62234743a244cad7cf7163c75e656178caa5a1d7c6757f0d708f2391
6
+ metadata.gz: 66f566988c4106206e84b287aece9b3595bfbca30b51b65a18ae5e534051b1896b967c6830d8765ac7c7c49e94745474c0777c41618bf73b0559762fb1e31e47
7
+ data.tar.gz: 0b44401eebd4070efbbda7227174f8b9fd7b943444683c8bfe1bf83d67efa5ae0935986e9be440e046230a41ea2ab21230c496cb32368a51509cfab8f5068fde
@@ -3,14 +3,12 @@ sudo: false
3
3
  cache: bundler
4
4
 
5
5
  rvm:
6
- - 1.9.3
7
6
  - 2.0
8
7
  - 2.1
8
+ - 2.2
9
9
 
10
10
  env:
11
- # - rails=3.1 # Don't need it in the CI matrix
12
11
  - rails=3.2.0
13
- - rails=4.0.0
14
12
  - rails=4.1.0
15
13
  - rails=4.2.0
16
14
 
@@ -26,21 +24,18 @@ services:
26
24
 
27
25
  matrix:
28
26
  exclude:
29
- - gemfile: gemfiles/Gemfile.mongoid2.rb
30
- env: rails=4.0.0
27
+ - env: rails=3.2.0
28
+ rvm: 2.2
29
+
31
30
  - gemfile: gemfiles/Gemfile.mongoid2.rb
32
31
  env: rails=4.1.0
33
32
  - gemfile: gemfiles/Gemfile.mongoid2.rb
34
33
  env: rails=4.2.0
35
34
 
36
- - gemfile: gemfiles/Gemfile.mongoid3.rb
37
- env: rails=4.0.0
38
35
  - gemfile: gemfiles/Gemfile.mongoid3.rb
39
36
  env: rails=4.1.0
40
37
  - gemfile: gemfiles/Gemfile.mongoid3.rb
41
38
  env: rails=4.2.0
42
39
 
43
- - gemfile: gemfiles/Gemfile.mongoid4.rb
44
- env: rails=3.1.0
45
40
  - gemfile: gemfiles/Gemfile.mongoid4.rb
46
41
  env: rails=3.2.0
@@ -1,12 +1,22 @@
1
1
  # Changelog
2
2
 
3
- ## 2.2.0 (unreleased)
3
+ ## 2.1.2
4
+
5
+ - [#574] Remove unused update authorization route.
6
+ - [#576] Filter out sensitive parameters from logs.
7
+ - [#582] The Authorization HTTP header fields are now case insensitive.
8
+ - [#583] Database connection bugfix in certain scenarios.
9
+ - Testing improvements
10
+
11
+
12
+ ## 2.1.1
4
13
 
5
14
  - Remove `wildcard_redirect_url` option
6
15
  - [#481] Customize token flow OAuth expirations with a config lambda
7
16
  - [#568] TokensController: Memoize strategy.authorize_response result to enable
8
17
  subclasses to use the response object.
9
18
  - [#571] Fix database initialization issues in some configurations.
19
+ - Documentation improvements
10
20
 
11
21
 
12
22
  ## 2.1.0
data/Gemfile CHANGED
@@ -7,5 +7,8 @@ gem 'rails', "~> #{ENV['rails']}"
7
7
  if ENV['rails'][0] == '4'
8
8
  gem 'database_cleaner'
9
9
  end
10
+ if ENV['rails'] =~ /4.0|3.2/
11
+ gem 'rubysl-test-unit'
12
+ end
10
13
 
11
14
  gemspec
data/README.md CHANGED
@@ -48,8 +48,8 @@ https://github.com/doorkeeper-gem/doorkeeper/releases.
48
48
 
49
49
  ## Requirements
50
50
 
51
- - Ruby >1.9.3
52
- - Rails >3.1
51
+ - Ruby >= 2.0.0
52
+ - Rails >= 3.2
53
53
  - ORM ActiveRecord, Mongoid, MongoMapper
54
54
 
55
55
  ## Installation
@@ -287,15 +287,15 @@ and take a look at the
287
287
  To run the local engine server:
288
288
 
289
289
  ```
290
- rails=3.2.8 orm=active_record bundle install
291
- rails=3.2.8 orm=active_record bundle exec rails server
290
+ bundle install
291
+ bundle exec rails server
292
292
  ````
293
293
 
294
294
  By default, it uses the latest Rails version with ActiveRecord. To run the
295
- tests:
295
+ tests with a specific ORM and Rails version:
296
296
 
297
297
  ```
298
- rails=3.2.8 orm=active_record bundle exec rake
298
+ rails=4.2.0 orm=active_record bundle exec rake
299
299
  ```
300
300
 
301
301
  Or you might prefer to run `script/run_all` to integrate against all ORMs.
@@ -7,5 +7,8 @@ gem 'rails', "~> #{ENV['rails']}"
7
7
  if ENV['rails'][0] == '4'
8
8
  gem 'database_cleaner', '~> 1.3.0'
9
9
  end
10
+ if ENV['rails'] =~ /4.0|3.2/
11
+ gem 'rubysl-test-unit'
12
+ end
10
13
 
11
14
  gemspec path: '../'
@@ -1,10 +1,14 @@
1
1
  module Doorkeeper
2
2
  class Engine < Rails::Engine
3
- initializer 'doorkeeper.routes' do
3
+ initializer "doorkeeper.params.filter" do |app|
4
+ app.config.filter_parameters += %i(client_secret code token)
5
+ end
6
+
7
+ initializer "doorkeeper.routes" do
4
8
  Doorkeeper::Rails::Routes.install!
5
9
  end
6
10
 
7
- initializer 'doorkeeper.helpers' do
11
+ initializer "doorkeeper.helpers" do
8
12
  ActiveSupport.on_load(:action_controller) do
9
13
  include Doorkeeper::Rails::Helpers
10
14
  end
@@ -11,13 +11,13 @@ module Doorkeeper
11
11
  end
12
12
 
13
13
  def from_bearer_authorization(request)
14
- pattern = /^Bearer /
14
+ pattern = /^Bearer /i
15
15
  header = request.authorization
16
16
  token_from_header(header, pattern) if match?(header, pattern)
17
17
  end
18
18
 
19
19
  def from_basic_authorization(request)
20
- pattern = /^Basic /
20
+ pattern = /^Basic /i
21
21
  header = request.authorization
22
22
  token_from_basic_header(header, pattern) if match?(header, pattern)
23
23
  end
@@ -7,7 +7,7 @@ module Doorkeeper
7
7
  require 'doorkeeper/orm/active_record/application'
8
8
 
9
9
  if Doorkeeper.configuration.active_record_options[:establish_connection]
10
- [Doorkeeper::AccessGrant, Doorkeeper::Application, Doorkeeper::AccessGrant].each do |c|
10
+ [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application].each do |c|
11
11
  c.send :establish_connection, Doorkeeper.configuration.active_record_options[:establish_connection]
12
12
  end
13
13
  end
@@ -3,53 +3,36 @@ module Doorkeeper
3
3
  module Helpers
4
4
  extend ActiveSupport::Concern
5
5
 
6
- module ClassMethods
7
- def doorkeeper_for(*args, &block)
8
- fail Errors::DoorkeeperError, "`doorkeeper_for` no longer available", <<-eos
9
- \nStarting in version 2.0.0 of doorkeeper gem, `doorkeeper_for` is no longer
10
- available. Please change `doorkeeper_for` calls in your application with:
11
-
12
- before_action :doorkeeper_authorize!
6
+ def doorkeeper_authorize!(*scopes)
7
+ @_doorkeeper_scopes = scopes || Doorkeeper.configuration.default_scopes
13
8
 
14
- For more information check the README:
15
- https://github.com/doorkeeper-gem/doorkeeper#protecting-resources-with-oauth-aka-your-api-endpoint\n
16
- eos
9
+ if doorkeeper_token_is_invalid?
10
+ doorkeeper_render_error
17
11
  end
18
12
  end
19
13
 
20
- def doorkeeper_token
21
- @_doorkeeper_token ||= OAuth::Token.authenticate request, *Doorkeeper.configuration.access_token_methods
14
+ def doorkeeper_unauthorized_render_options
15
+ nil
22
16
  end
23
17
 
24
- def valid_doorkeeper_token?(*scopes)
25
- doorkeeper_token && doorkeeper_token.acceptable?(scopes)
18
+ def doorkeeper_forbidden_render_options
19
+ nil
26
20
  end
27
21
 
28
- def doorkeeper_authorize!(*scopes)
29
- scopes ||= Doorkeeper.configuration.default_scopes
30
-
31
- unless valid_doorkeeper_token?(*scopes)
32
- if !doorkeeper_token || !doorkeeper_token.accessible?
33
- error = OAuth::InvalidTokenResponse.from_access_token(doorkeeper_token)
34
- options = doorkeeper_unauthorized_render_options
35
- else
36
- error = OAuth::ForbiddenTokenResponse.from_scopes(scopes)
37
- options = doorkeeper_forbidden_render_options
38
- end
39
- headers.merge!(error.headers.reject { |k| ['Content-Type'].include? k })
40
- doorkeeper_error_renderer(error, options)
41
- end
42
- end
22
+ private
43
23
 
44
- def doorkeeper_unauthorized_render_options
45
- nil
24
+ def doorkeeper_token_is_invalid?
25
+ !doorkeeper_token || !doorkeeper_token.acceptable?(@_doorkeeper_scopes)
46
26
  end
47
27
 
48
- def doorkeeper_forbidden_render_options
49
- nil
28
+ def doorkeeper_render_error
29
+ error = doorkeeper_error
30
+ headers.merge! error.headers.reject { |k| "Content-Type" == k }
31
+ doorkeeper_render_error_with(error)
50
32
  end
51
33
 
52
- def doorkeeper_error_renderer(error, options = {})
34
+ def doorkeeper_render_error_with(error)
35
+ options = doorkeeper_render_options || {}
53
36
  if options.blank?
54
37
  head error.status
55
38
  else
@@ -58,6 +41,51 @@ https://github.com/doorkeeper-gem/doorkeeper#protecting-resources-with-oauth-aka
58
41
  render options
59
42
  end
60
43
  end
44
+
45
+ def doorkeeper_error
46
+ if doorkeeper_invalid_token_response?
47
+ OAuth::InvalidTokenResponse.from_access_token(doorkeeper_token)
48
+ else
49
+ OAuth::ForbiddenTokenResponse.from_scopes(@_doorkeeper_scopes)
50
+ end
51
+ end
52
+
53
+ def doorkeeper_render_options
54
+ if doorkeeper_invalid_token_response?
55
+ doorkeeper_unauthorized_render_options
56
+ else
57
+ doorkeeper_forbidden_render_options
58
+ end
59
+ end
60
+
61
+ def doorkeeper_invalid_token_response?
62
+ !doorkeeper_token || !doorkeeper_token.accessible?
63
+ end
64
+
65
+ def doorkeeper_token
66
+ @_doorkeeper_token ||= OAuth::Token.authenticate(
67
+ request,
68
+ *Doorkeeper.configuration.access_token_methods
69
+ )
70
+ end
71
+
72
+ module ClassMethods
73
+ def doorkeeper_for(*_args)
74
+ fail(
75
+ Errors::DoorkeeperError,
76
+ "`doorkeeper_for` no longer available",
77
+ <<-eos
78
+ \nStarting in version 2.0.0 of doorkeeper gem, `doorkeeper_for` is no longer
79
+ available. Please change `doorkeeper_for` calls in your application with:
80
+
81
+ before_action :doorkeeper_authorize!
82
+
83
+ For more information check the README:
84
+ https://github.com/doorkeeper-gem/doorkeeper#protecting-resources-with-oauth-aka-your-api-endpoint\n
85
+ eos
86
+ )
87
+ end
88
+ end
61
89
  end
62
90
  end
63
91
  end
@@ -45,7 +45,7 @@ module Doorkeeper
45
45
  routes.resource(
46
46
  :authorization,
47
47
  path: 'authorize',
48
- only: [:create, :update, :destroy],
48
+ only: [:create, :destroy],
49
49
  as: mapping[:as],
50
50
  controller: mapping[:controllers]
51
51
  ) do
@@ -1,3 +1,3 @@
1
1
  module Doorkeeper
2
- VERSION = '2.1.1'
2
+ VERSION = '2.1.2'
3
3
  end
@@ -56,12 +56,18 @@ module Doorkeeper
56
56
  end
57
57
 
58
58
  describe :from_bearer_authorization do
59
- it 'returns token from authorization bearer' do
59
+ it 'returns token from capitalized authorization bearer' do
60
60
  request = double authorization: 'Bearer SomeToken'
61
61
  token = Token.from_bearer_authorization(request)
62
62
  expect(token).to eq('SomeToken')
63
63
  end
64
64
 
65
+ it 'returns token from lowercased authorization bearer' do
66
+ request = double authorization: 'bearer SomeToken'
67
+ token = Token.from_bearer_authorization(request)
68
+ expect(token).to eq('SomeToken')
69
+ end
70
+
65
71
  it 'does not return token if authorization is not bearer' do
66
72
  request = double authorization: 'MAC SomeToken'
67
73
  token = Token.from_bearer_authorization(request)
@@ -70,12 +76,18 @@ module Doorkeeper
70
76
  end
71
77
 
72
78
  describe :from_basic_authorization do
73
- it 'returns token from authorization basic' do
79
+ it 'returns token from capitalized authorization basic' do
74
80
  request = double authorization: "Basic #{Base64.encode64 'SomeToken:'}"
75
81
  token = Token.from_basic_authorization(request)
76
82
  expect(token).to eq('SomeToken')
77
83
  end
78
84
 
85
+ it 'returns token from lowercased authorization basic' do
86
+ request = double authorization: "basic #{Base64.encode64 'SomeToken:'}"
87
+ token = Token.from_basic_authorization(request)
88
+ expect(token).to eq('SomeToken')
89
+ end
90
+
79
91
  it 'does not return token if authorization is not basic' do
80
92
  request = double authorization: "MAC #{Base64.encode64 'SomeToken:'}"
81
93
  token = Token.from_basic_authorization(request)
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.1
4
+ version: 2.1.2
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-02-06 00:00:00.000000000 Z
12
+ date: 2015-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties