doorkeeper-device_authorization_grant 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/doorkeeper/device_authorization_grant/device_authorizations_controller.rb +2 -2
- data/lib/doorkeeper/device_authorization_grant/config.rb +1 -1
- data/lib/doorkeeper/device_authorization_grant/oauth/device_authorization_request.rb +1 -2
- data/lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb +1 -1
- data/lib/doorkeeper/device_authorization_grant/oauth/device_code_request.rb +21 -4
- data/lib/doorkeeper/device_authorization_grant/orm/active_record/device_grant.rb +1 -1
- data/lib/doorkeeper/device_authorization_grant/orm/active_record/device_grant_mixin.rb +2 -2
- data/lib/doorkeeper/device_authorization_grant/version.rb +1 -1
- metadata +26 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 918728396ff79ae1d4efcc5343698057ba21f210ba1337ca4f9e5506b7c93270
|
4
|
+
data.tar.gz: 40c2be408c998eb5c6c27c9feaa384cd7d028488b1c74bbedee9f93625a0d00f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee2ed1c9be3d69d8aee4429c84b46b49845c266c06e0337b71b9798dea6701009b86926bc413441a8b5c82500521ea70f060a52197123d8c75ddf1e76b274370
|
7
|
+
data.tar.gz: e38f960d8d614c201fa5062142c7c22670c30fff51173e506ae4aa5efcff78ec86482583363bc79fcfcbb7520f44cf0066d3e252fcb6ec1578794077c90456d7
|
data/app/controllers/doorkeeper/device_authorization_grant/device_authorizations_controller.rb
CHANGED
@@ -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
|
-
|
22
|
-
|
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
|
-
|
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
|
)
|
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.
|
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:
|
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.
|
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.
|
40
|
+
version: '1.23'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rubocop-
|
42
|
+
name: rubocop-performance
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
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: '
|
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.
|
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
|
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
|
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.
|
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.
|
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.
|
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.
|