doorkeeper-device_authorization_grant 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +2 -25
- data/Rakefile +1 -15
- data/lib/doorkeeper/device_authorization_grant.rb +8 -0
- data/lib/doorkeeper/device_authorization_grant/oauth.rb +12 -0
- data/lib/doorkeeper/device_authorization_grant/oauth/device_code_request.rb +1 -2
- data/lib/doorkeeper/device_authorization_grant/version.rb +1 -1
- metadata +22 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32ee06252abdee845d51559423b8acb6c52e95d6114a77829281fbfbe3b92cb2
|
4
|
+
data.tar.gz: 7808d08e1884a3e8755477a66527218fcde0a939d7c9c0aa896ff995255b1f9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0774bd3547873749fc1f5e0f6e76ccbe600809e085b290d776e53ebc88f4269e4199e6bc309ecd773952f93c73dadb4011d3b9cf69e4690b34034ce96e3afc06
|
7
|
+
data.tar.gz: be2761dd89889be684363b1f33ca69774f059baff4fddf4056e9b83d8037d06f6b0fd64c36ee2d95c51e2536121f613b5a982f7fc6da909196b82c8ed2be7bef
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -7,17 +7,6 @@ This library implements the OAuth 2.0 device authorization grant
|
|
7
7
|
[Ruby on Rails](https://rubyonrails.org/) applications on top of the
|
8
8
|
[Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) OAuth 2.0 framework.
|
9
9
|
|
10
|
-
## Status
|
11
|
-
|
12
|
-
This extension currently works with Doorkeeper version `>= 5.4.0`.
|
13
|
-
|
14
|
-
As of June 25 2020, due to some limitations of Doorkeeper, it is currently
|
15
|
-
inconvenient for this Gem to use the official OAuth grant type
|
16
|
-
`urn:ietf:params:oauth:grant-type:device_code`. Instead, it has been renamed
|
17
|
-
to simply `device_code`, which is non-standard. This is going to be corrected
|
18
|
-
soon: the next Doorkeeper release will include the ability to cleanly
|
19
|
-
register custom Grant Flows - see [Doorkeeper Pull Request #1418](https://github.com/doorkeeper-gem/doorkeeper/pull/1418).
|
20
|
-
|
21
10
|
## Installation
|
22
11
|
|
23
12
|
Add this line to your application's Gemfile:
|
@@ -55,7 +44,7 @@ $ rails doorkeeper_device_authorization_grant_engine:install:migrations
|
|
55
44
|
### Doorkeeper configuration
|
56
45
|
|
57
46
|
In your Doorkeeper initializer (usually `config/initializers/doorkeeper.rb`), enable
|
58
|
-
the
|
47
|
+
the new grant flow extension, adding to the `grant_flows` option the `device_code`
|
59
48
|
string. For example:
|
60
49
|
|
61
50
|
```ruby
|
@@ -65,9 +54,6 @@ string. For example:
|
|
65
54
|
# ...
|
66
55
|
|
67
56
|
grant_flows [
|
68
|
-
# Note: this is a non-standard grant flow, used instead of the
|
69
|
-
# official `urn:ietf:params:oauth:grant-type:device_code` due to
|
70
|
-
# current Doorkeeper limitations.
|
71
57
|
'device_code',
|
72
58
|
|
73
59
|
# together with all the other grant flows you already enabled, for example:
|
@@ -80,11 +66,6 @@ string. For example:
|
|
80
66
|
end
|
81
67
|
```
|
82
68
|
|
83
|
-
Please note that **this is not the official grant flow**. The real one should be
|
84
|
-
the IANA URN `urn:ietf:params:oauth:grant-type:device_code`, however this is hard
|
85
|
-
to support with the current version of Doorkeeper, due to how strategy classes are
|
86
|
-
looked up by grant type value.
|
87
|
-
|
88
69
|
### Device Authorization Grant configuration
|
89
70
|
|
90
71
|
The gem's installation scripts automatically creates a new initializer file:
|
@@ -237,15 +218,11 @@ by Dorkeeper), for example:
|
|
237
218
|
POST /oauth/token HTTP/1.1
|
238
219
|
Content-Type: application/x-www-form-urlencoded
|
239
220
|
|
240
|
-
grant_type=device_code
|
221
|
+
grant_type=urn:ietf:params:oauth:grant-type:device_code
|
241
222
|
&device_code=GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS
|
242
223
|
&client_id=1406020730
|
243
224
|
```
|
244
225
|
|
245
|
-
**Note:** this is a non-standard `grant_type`, used instead of the official
|
246
|
-
`urn:ietf:params:oauth:grant-type:device_code` due to current limitations of
|
247
|
-
the Doorkeeper gem.
|
248
|
-
|
249
226
|
The response to this request is defined in the next section. It is expected for
|
250
227
|
the *Device Client* to try the access token request repeatedly in a polling
|
251
228
|
fashion, based on the error code in the response. The polling time interval
|
data/Rakefile
CHANGED
@@ -1,20 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
rescue LoadError
|
6
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'rdoc/task'
|
10
|
-
|
11
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
-
rdoc.rdoc_dir = 'rdoc'
|
13
|
-
rdoc.title = 'Doorkeeper::DeviceAuthorizationGrant'
|
14
|
-
rdoc.options << '--line-numbers'
|
15
|
-
rdoc.rdoc_files.include('README.md')
|
16
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
17
|
-
end
|
3
|
+
require 'bundler/setup'
|
18
4
|
|
19
5
|
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
20
6
|
load 'rails/tasks/engine.rake'
|
@@ -5,12 +5,14 @@ require 'active_model'
|
|
5
5
|
require 'doorkeeper/device_authorization_grant/config'
|
6
6
|
require 'doorkeeper/device_authorization_grant/engine'
|
7
7
|
|
8
|
+
# Doorkeeper namespace
|
8
9
|
module Doorkeeper
|
9
10
|
# OAuth 2.0 Device Authorization Grant extension for Doorkeeper.
|
10
11
|
module DeviceAuthorizationGrant
|
11
12
|
autoload :DeviceGrant, 'doorkeeper/device_authorization_grant/orm/active_record/device_grant'
|
12
13
|
autoload :DeviceGrantMixin, 'doorkeeper/device_authorization_grant/orm/active_record/device_grant_mixin'
|
13
14
|
autoload :Errors, 'doorkeeper/device_authorization_grant/errors'
|
15
|
+
autoload :OAuth, 'doorkeeper/device_authorization_grant/oauth'
|
14
16
|
autoload :VERSION, 'doorkeeper/device_authorization_grant/version'
|
15
17
|
|
16
18
|
# Namespace for device authorization request strategies
|
@@ -45,4 +47,10 @@ module Doorkeeper
|
|
45
47
|
module Request
|
46
48
|
autoload :DeviceCode, 'doorkeeper/request/device_code'
|
47
49
|
end
|
50
|
+
|
51
|
+
Doorkeeper::GrantFlow.register(
|
52
|
+
:device_code,
|
53
|
+
grant_type_matches: Doorkeeper::DeviceAuthorizationGrant::OAuth::DEVICE_CODE,
|
54
|
+
grant_type_strategy: Doorkeeper::Request::DeviceCode
|
55
|
+
)
|
48
56
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Doorkeeper
|
4
|
+
module DeviceAuthorizationGrant
|
5
|
+
module OAuth
|
6
|
+
# IANA URN of the Device Authorization Grant Type.
|
7
|
+
# @see https://tools.ietf.org/html/rfc8628#section-7.2 RFC 8628 - 7.2. OAuth URI Registration
|
8
|
+
DEVICE_CODE = 'urn:ietf:params:oauth:grant-type:device_code'
|
9
|
+
public_constant :DEVICE_CODE
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -27,8 +27,7 @@ module Doorkeeper
|
|
27
27
|
@client = client
|
28
28
|
@device_grant = device_grant
|
29
29
|
|
30
|
-
|
31
|
-
@grant_type = 'device_code'
|
30
|
+
@grant_type = Doorkeeper::DeviceAuthorizationGrant::OAuth::DEVICE_CODE
|
32
31
|
end
|
33
32
|
|
34
33
|
def before_successful_response
|
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: 0.
|
4
|
+
version: 1.0.0
|
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-
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: doorkeeper
|
@@ -16,56 +16,62 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.14'
|
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.14'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: '2.10'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.10.1
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - "~>"
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
57
|
+
version: '2.10'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.10.1
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: simplecov
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.21.
|
67
|
+
version: 0.21.2
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.21.
|
74
|
+
version: 0.21.2
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: sqlite3
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,6 +119,7 @@ files:
|
|
113
119
|
- lib/doorkeeper/device_authorization_grant/config.rb
|
114
120
|
- lib/doorkeeper/device_authorization_grant/engine.rb
|
115
121
|
- lib/doorkeeper/device_authorization_grant/errors.rb
|
122
|
+
- lib/doorkeeper/device_authorization_grant/oauth.rb
|
116
123
|
- lib/doorkeeper/device_authorization_grant/oauth/device_authorization_request.rb
|
117
124
|
- lib/doorkeeper/device_authorization_grant/oauth/device_authorization_response.rb
|
118
125
|
- lib/doorkeeper/device_authorization_grant/oauth/device_code_request.rb
|
@@ -131,7 +138,10 @@ files:
|
|
131
138
|
homepage: https://github.com/exop-group/doorkeeper-device_authorization_grant
|
132
139
|
licenses:
|
133
140
|
- MIT
|
134
|
-
metadata:
|
141
|
+
metadata:
|
142
|
+
homepage_uri: https://github.com/exop-group/doorkeeper-device_authorization_grant
|
143
|
+
source_code_uri: https://github.com/exop-group/doorkeeper-device_authorization_grant
|
144
|
+
changelog_uri: https://github.com/exop-group/doorkeeper-device_authorization_grant/blob/master/CHANGELOG.md
|
135
145
|
post_install_message:
|
136
146
|
rdoc_options: []
|
137
147
|
require_paths:
|
@@ -147,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
157
|
- !ruby/object:Gem::Version
|
148
158
|
version: '0'
|
149
159
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
160
|
+
rubygems_version: 3.2.15
|
151
161
|
signing_key:
|
152
162
|
specification_version: 4
|
153
163
|
summary: OAuth 2.0 Device Authorization Grant extension for Doorkeeper.
|