model_driven_api 3.2.7 → 3.2.8
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66f79849229a707224dc7cfdb61e3cb53995e2ba6e4b01c7485f9b1115791dfb
|
4
|
+
data.tar.gz: d5ba4ba9e7e4c0d750683c230e63d3f3d9f7785c64e4fee8da96f06ea52dc1b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0578ec016dc2dd7fcee4eef1fed2fcd765ed13a9a1391383911fbeb336b2a8654efee5d043a3a803dd2af83440a83048315b9034873bd19f155bd3326f4d51ae'
|
7
|
+
data.tar.gz: 484370bc4395eeb5782180875f470784ca02dcf1b3431da82e491b21545aef86f2d254744fbbe5be5675f09dd2e30ed85ceb77051c9d78cd7b40dfe731015c3a
|
@@ -14,17 +14,28 @@ class AuthorizeApiRequest
|
|
14
14
|
attr_reader :headers
|
15
15
|
|
16
16
|
def api_user
|
17
|
+
Rails.logger.debug "AuthorizeApiRequest: api_user -> #{decoded_auth_token}"
|
17
18
|
@api_user ||= User.find(decoded_auth_token[:user_id]) if decoded_auth_token
|
18
|
-
@api_user
|
19
|
+
if @api_user
|
20
|
+
return @api_user
|
21
|
+
else
|
22
|
+
errors.add(:token, "Invalid token")
|
23
|
+
return nil
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
27
|
def decoded_auth_token
|
28
|
+
Rails.logger.debug "AuthorizeApiRequest: http_auth_header -> #{http_auth_header}"
|
22
29
|
@decoded_auth_token ||= JsonWebToken.decode(http_auth_header)
|
30
|
+
@decoded_auth_token
|
23
31
|
end
|
24
32
|
|
25
33
|
def http_auth_header
|
34
|
+
Rails.logger.debug "AuthorizeApiRequest: Authorization -> #{headers['Authorization']}"
|
26
35
|
if headers['Authorization'].present?
|
27
|
-
|
36
|
+
token = headers['Authorization'].split(' ').last
|
37
|
+
Rails.logger.debug "AuthorizeApiRequest: token -> #{token}"
|
38
|
+
return token
|
28
39
|
else
|
29
40
|
errors.add(:token, "Missing token")
|
30
41
|
end
|
@@ -195,9 +195,11 @@ class Api::V2::ApplicationController < ActionController::API
|
|
195
195
|
@current_user = nil
|
196
196
|
Settings.ns(:security).allowed_authorization_headers.split(",").each do |header|
|
197
197
|
# puts "Found header #{header}: #{request.headers[header]}"
|
198
|
-
check_authorization("Authorize#{header}".constantize.call(request))
|
198
|
+
check_authorization("Authorize#{header}".constantize.call(request)) unless @current_user
|
199
199
|
end
|
200
200
|
|
201
|
+
Rails.logger.debug("Checking for authorization with AuthorizeApiRequest if current_user not already present -> current_user: #{@current_user}")
|
202
|
+
|
201
203
|
check_authorization AuthorizeApiRequest.call(request) unless @current_user
|
202
204
|
return unauthenticated!(OpenStruct.new({ message: @auth_errors })) unless @current_user
|
203
205
|
|
@@ -240,6 +242,7 @@ class Api::V2::ApplicationController < ActionController::API
|
|
240
242
|
end
|
241
243
|
|
242
244
|
def check_authorization(cmd)
|
245
|
+
Rails.logger.debug("Checking authorization: #{cmd.inspect}")
|
243
246
|
if cmd.success?
|
244
247
|
@current_user = cmd.result
|
245
248
|
else
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_driven_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-02-12 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: thecore_backend_commons
|