doorkeeper-device_authorization_grant 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a95bd7a093b27e1735e590152c1eb72b0d24ddfe24769ef096bdfed7e5085fe7
4
- data.tar.gz: 787d3736c5b2689191d505d67bd997c6ead61a6ca6f5c41233fde9c25d9cbc3e
3
+ metadata.gz: 918728396ff79ae1d4efcc5343698057ba21f210ba1337ca4f9e5506b7c93270
4
+ data.tar.gz: 40c2be408c998eb5c6c27c9feaa384cd7d028488b1c74bbedee9f93625a0d00f
5
5
  SHA512:
6
- metadata.gz: aa55bc03f056f52064fd0defd3f8562508e62af6006cf28ba60cb1371a6f89ca1d5109f33a1d36639fdc8fdafecda7c6cf934a04c99ac169d158fc41318f7775
7
- data.tar.gz: 335a27953d47a3ee17e6052510f9cfdd75cc55eaaacac1cd0e8b76b1eea8c09a4dbd573ba41ab4d68f0bda34da36a115a0dd2c7601e4640c1171b87e06ce8dc0
6
+ metadata.gz: ee2ed1c9be3d69d8aee4429c84b46b49845c266c06e0337b71b9798dea6701009b86926bc413441a8b5c82500521ea70f060a52197123d8c75ddf1e76b274370
7
+ data.tar.gz: e38f960d8d614c201fa5062142c7c22670c30fff51173e506ae4aa5efcff78ec86482583363bc79fcfcbb7520f44cf0066d3e252fcb6ec1578794077c90456d7
@@ -18,8 +18,8 @@ module Doorkeeper
18
18
  def authorize
19
19
  device_grant_model.transaction do
20
20
  device_grant = device_grant_model.lock.find_by(user_code: user_code)
21
- return authorization_error_response(:invalid_user_code) if device_grant.nil?
22
- return authorization_error_response(:expired_user_code) if device_grant.expired?
21
+ next authorization_error_response(:invalid_user_code) if device_grant.nil?
22
+ next authorization_error_response(:expired_user_code) if device_grant.expired?
23
23
 
24
24
  device_grant.update!(user_code: nil, resource_owner_id: current_resource_owner.id)
25
25
  end
@@ -20,7 +20,7 @@ module Doorkeeper
20
20
  def initialize
21
21
  super(
22
22
  'Configuration for Doorkeeper::DeviceAuthorizationGrant missing. ' \
23
- 'Do you have Doorkeeper::DeviceAuthorizationGrant initializer?'
23
+ 'Do you have Doorkeeper::DeviceAuthorizationGrant initializer?'
24
24
  )
25
25
  end
26
26
  end
@@ -7,8 +7,7 @@ module Doorkeeper
7
7
  #
8
8
  # @see https://tools.ietf.org/html/rfc8628#section-3.1 RFC 8628, sect. 3.1
9
9
  class DeviceAuthorizationRequest < Doorkeeper::OAuth::BaseRequest
10
- attr_accessor :server,
11
- :client
10
+ attr_accessor :server, :client
12
11
 
13
12
  # @return [String]
14
13
  attr_accessor :host_name
@@ -35,7 +35,7 @@ module Doorkeeper
35
35
  'verification_uri_complete' => verification_uri_complete,
36
36
  'expires_in' => device_grant.expires_in,
37
37
  'interval' => interval
38
- }.reject { |_, value| value.blank? }
38
+ }.reject { |_, value| value.blank? } # rubocop:disable Rails/CompactBlank does not exist in Rails < 6.1
39
39
  end
40
40
 
41
41
  # @return [Hash]
@@ -7,9 +7,7 @@ module Doorkeeper
7
7
  #
8
8
  # @see https://tools.ietf.org/html/rfc8628#section-3.4 RFC 8628, sect. 3.4
9
9
  class DeviceCodeRequest < ::Doorkeeper::OAuth::BaseRequest
10
- attr_accessor :server,
11
- :client,
12
- :access_token
10
+ attr_accessor :server, :client, :access_token
13
11
 
14
12
  # @return [DeviceGrant]
15
13
  attr_accessor :device_grant
@@ -46,6 +44,25 @@ module Doorkeeper
46
44
  private
47
45
 
48
46
  def generate_access_token
47
+ # Doorkeeper 5.6.5 introduced an additional argument, see https://github.com/doorkeeper-gem/doorkeeper/pull/1602
48
+ if Doorkeeper.gem_version >= Gem::Version.new('5.6.5')
49
+ generate_access_token_with_empty_custom_attributes
50
+ else
51
+ generate_access_token_without_custom_attributes
52
+ end
53
+ end
54
+
55
+ def generate_access_token_with_empty_custom_attributes
56
+ find_or_create_access_token(
57
+ device_grant.application,
58
+ device_grant.resource_owner_id,
59
+ device_grant.scopes,
60
+ {},
61
+ server
62
+ )
63
+ end
64
+
65
+ def generate_access_token_without_custom_attributes
49
66
  find_or_create_access_token(
50
67
  device_grant.application,
51
68
  device_grant.resource_owner_id,
@@ -64,7 +81,7 @@ module Doorkeeper
64
81
  def check_user_interaction!
65
82
  raise Errors::SlowDown if polling_too_fast?
66
83
 
67
- device_grant.update!(last_polling_at: Time.now)
84
+ device_grant.update!(last_polling_at: Time.now.utc)
68
85
 
69
86
  raise Errors::AuthorizationPending if authorization_pending?
70
87
  end
@@ -4,7 +4,7 @@ module Doorkeeper
4
4
  module DeviceAuthorizationGrant
5
5
  # Model class, similar to Doorkeeper `AccessGrant`, but specific for
6
6
  # handling OAuth 2.0 Device Authorization Grant.
7
- class DeviceGrant < ActiveRecord::Base
7
+ class DeviceGrant < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord Doorkeeper models inherit from ActiveRecord::Base.
8
8
  include DeviceGrantMixin
9
9
 
10
10
  # @!attribute application_id
@@ -15,7 +15,7 @@ module Doorkeeper
15
15
 
16
16
  delegate :secret_strategy, :fallback_secret_strategy, to: :class
17
17
 
18
- belongs_to :application, class_name: Doorkeeper.configuration.application_class, optional: true
18
+ belongs_to :application, class_name: Doorkeeper.configuration.application_class.to_s, optional: true
19
19
 
20
20
  before_validation :generate_device_code, on: :create
21
21
 
@@ -130,7 +130,7 @@ module Doorkeeper
130
130
  end
131
131
 
132
132
  def scopes_match_configured
133
- if scopes.present? && !Doorkeeper::OAuth::Helpers::ScopeChecker.valid?(
133
+ if scopes.present? && !Doorkeeper::OAuth::Helpers::ScopeChecker.valid?( # rubocop:disable Style/InverseMethods
134
134
  scope_str: scopes.to_s,
135
135
  server_scopes: Doorkeeper.config.scopes
136
136
  )
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Doorkeeper
4
4
  module DeviceAuthorizationGrant
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
6
6
  public_constant :VERSION
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeeper-device_authorization_grant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - EXOP Group
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-03 00:00:00.000000000 Z
11
+ date: 2023-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: doorkeeper
@@ -30,34 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.14'
33
+ version: '1.23'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.14'
40
+ version: '1.23'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rubocop-rails
42
+ name: rubocop-performance
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.10'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 2.10.1
47
+ version: '1.12'
51
48
  type: :development
52
49
  prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - "~>"
56
53
  - !ruby/object:Gem::Version
57
- version: '2.10'
58
- - - ">="
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
59
67
  - !ruby/object:Gem::Version
60
- version: 2.10.1
68
+ version: '2.12'
61
69
  - !ruby/object:Gem::Dependency
62
70
  name: simplecov
63
71
  requirement: !ruby/object:Gem::Requirement
@@ -78,28 +86,28 @@ dependencies:
78
86
  requirements:
79
87
  - - "~>"
80
88
  - !ruby/object:Gem::Version
81
- version: 1.4.2
89
+ version: '1.4'
82
90
  type: :development
83
91
  prerelease: false
84
92
  version_requirements: !ruby/object:Gem::Requirement
85
93
  requirements:
86
94
  - - "~>"
87
95
  - !ruby/object:Gem::Version
88
- version: 1.4.2
96
+ version: '1.4'
89
97
  - !ruby/object:Gem::Dependency
90
98
  name: yard
91
99
  requirement: !ruby/object:Gem::Requirement
92
100
  requirements:
93
101
  - - "~>"
94
102
  - !ruby/object:Gem::Version
95
- version: 0.9.26
103
+ version: 0.9.27
96
104
  type: :development
97
105
  prerelease: false
98
106
  version_requirements: !ruby/object:Gem::Requirement
99
107
  requirements:
100
108
  - - "~>"
101
109
  - !ruby/object:Gem::Version
102
- version: 0.9.26
110
+ version: 0.9.27
103
111
  description: OAuth 2.0 Device Authorization Grant extension for Doorkeeper.
104
112
  email:
105
113
  - opensource@exop-group.com
@@ -142,6 +150,7 @@ metadata:
142
150
  homepage_uri: https://github.com/exop-group/doorkeeper-device_authorization_grant
143
151
  source_code_uri: https://github.com/exop-group/doorkeeper-device_authorization_grant
144
152
  changelog_uri: https://github.com/exop-group/doorkeeper-device_authorization_grant/blob/master/CHANGELOG.md
153
+ rubygems_mfa_required: 'true'
145
154
  post_install_message:
146
155
  rdoc_options: []
147
156
  require_paths:
@@ -157,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
166
  - !ruby/object:Gem::Version
158
167
  version: '0'
159
168
  requirements: []
160
- rubygems_version: 3.0.8
169
+ rubygems_version: 3.3.7
161
170
  signing_key:
162
171
  specification_version: 4
163
172
  summary: OAuth 2.0 Device Authorization Grant extension for Doorkeeper.