doorkeeper-device_authorization_grant 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/doorkeeper/device_authorization_grant/device_codes_controller.rb +1 -1
- data/config/locales/en.yml +7 -0
- data/lib/doorkeeper/device_authorization_grant/oauth/device_authorization_request.rb +3 -1
- data/lib/doorkeeper/device_authorization_grant/orm/active_record/device_grant_mixin.rb +15 -1
- data/lib/doorkeeper/device_authorization_grant/request/device_authorization.rb +3 -2
- data/lib/doorkeeper/device_authorization_grant/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87c9de51f80c701da39179d542265e15fc426cefdff8b7b70827305d27c89a16
|
4
|
+
data.tar.gz: '028cb5145903789550175cb6acdec567a214d4b84186d9e08fb9274b4016a4f3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667775d114f8a4559eaf84e84e8806acbdae0555bacb57db2c13a73d07dc447a60a2e135b837ffb42382e403f43774ce02f9933e619a0a6a28b291f771898f33
|
7
|
+
data.tar.gz: d8e6b3a77372b2dfe23e4a5f65d669878403b3ed803e1b66861d9c8c1279d3b7ecad1c97313a74475bd0a2ecc107e81410f74f9bf5de259a94a1292d48b1701c
|
@@ -9,7 +9,7 @@ module Doorkeeper
|
|
9
9
|
def create
|
10
10
|
headers.merge!(authorize_response.headers)
|
11
11
|
render(json: authorize_response.body, status: authorize_response.status)
|
12
|
-
rescue Errors::DoorkeeperError => e
|
12
|
+
rescue Doorkeeper::Errors::DoorkeeperError => e
|
13
13
|
handle_token_exception(e)
|
14
14
|
end
|
15
15
|
|
data/config/locales/en.yml
CHANGED
@@ -18,11 +18,13 @@ module Doorkeeper
|
|
18
18
|
# @param server
|
19
19
|
# @param client
|
20
20
|
# @param host_name [String]
|
21
|
-
|
21
|
+
# @param parameters [Hash]
|
22
|
+
def initialize(server, client, host_name, parameters = {}) # rubocop:disable Style/OptionHash
|
22
23
|
super()
|
23
24
|
@server = server
|
24
25
|
@client = client
|
25
26
|
@host_name = host_name
|
27
|
+
@original_scopes = parameters[:scope]
|
26
28
|
end
|
27
29
|
|
28
30
|
# @return [DeviceAuthorizationResponse, Doorkeeper::OAuth::ErrorResponse]
|
@@ -10,7 +10,7 @@ module Doorkeeper
|
|
10
10
|
extend ActiveSupport::Concern
|
11
11
|
include ::Doorkeeper::Models::Expirable
|
12
12
|
|
13
|
-
included do
|
13
|
+
included do # rubocop:disable Metrics/BlockLength
|
14
14
|
self.table_name = "#{table_name_prefix}oauth_device_grants#{table_name_suffix}"
|
15
15
|
|
16
16
|
delegate :secret_strategy, :fallback_secret_strategy, to: :class
|
@@ -28,6 +28,7 @@ module Doorkeeper
|
|
28
28
|
|
29
29
|
validates :resource_owner_id, presence: true, if: -> { user_code.blank? }
|
30
30
|
validates :resource_owner_id, absence: true, if: -> { user_code.present? }
|
31
|
+
validate :scopes_match_configured, if: :enforce_scopes?
|
31
32
|
|
32
33
|
scope(
|
33
34
|
:expired,
|
@@ -127,6 +128,19 @@ module Doorkeeper
|
|
127
128
|
@raw_device_code = Doorkeeper::OAuth::Helpers::UniqueToken.generate
|
128
129
|
secret_strategy.store_secret(self, :device_code, @raw_device_code)
|
129
130
|
end
|
131
|
+
|
132
|
+
def scopes_match_configured
|
133
|
+
if scopes.present? && !Doorkeeper::OAuth::Helpers::ScopeChecker.valid?(
|
134
|
+
scope_str: scopes.to_s,
|
135
|
+
server_scopes: Doorkeeper.config.scopes
|
136
|
+
)
|
137
|
+
errors.add(:scopes, :not_match_configured)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def enforce_scopes?
|
142
|
+
Doorkeeper.config.enforce_configured_scopes?
|
143
|
+
end
|
130
144
|
end
|
131
145
|
end
|
132
146
|
end
|
@@ -7,14 +7,15 @@ module Doorkeeper
|
|
7
7
|
#
|
8
8
|
# @see https://tools.ietf.org/html/rfc8628#section-3.1 RFC 8628, sect. 3.1
|
9
9
|
class DeviceAuthorization < ::Doorkeeper::Request::Strategy
|
10
|
-
delegate :client, to: :server
|
10
|
+
delegate :client, :parameters, to: :server
|
11
11
|
|
12
12
|
# @return [OAuth::DeviceAuthorizationRequest]
|
13
13
|
def request
|
14
14
|
@request ||= OAuth::DeviceAuthorizationRequest.new(
|
15
15
|
Doorkeeper.configuration,
|
16
16
|
client,
|
17
|
-
host_name
|
17
|
+
host_name,
|
18
|
+
parameters
|
18
19
|
)
|
19
20
|
end
|
20
21
|
|
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.2.
|
4
|
+
version: 0.2.1
|
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-01-
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: doorkeeper
|