model_driven_api 3.3.0 → 3.3.1
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: 0751f2c240c15ab7130628b14469555a3fb1abf74e80fba20c86b6a588c4d2db
|
4
|
+
data.tar.gz: 573b9acc768a3162a449e3c70890a1ab5be0e2b124eca9d0d3f6a25fc9928aba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ace22af5f8fd756d69b251d4576997e907e38c275706960aa3b31a2149c63744506792f5995e604b0ec68fd08f8bae2f256e4013a43af7ae10a10474c018eaba
|
7
|
+
data.tar.gz: 961a3a7b3378981df8078b6b7369cc8eb1fb3cada953553de4e2cf2f677583ec6050a968bd3d6d85b483279ca9d24b9796ae06f5d8448bec944f6ca2fc601d2a
|
@@ -25,16 +25,16 @@ class AuthorizeApiRequest
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def decoded_auth_token
|
28
|
-
Rails.logger.debug "AuthorizeApiRequest: http_auth_header -> #{http_auth_header}"
|
28
|
+
Rails.logger.debug "AuthorizeApiRequest: decoded_auth_token -> http_auth_header -> #{http_auth_header}"
|
29
29
|
@decoded_auth_token ||= JsonWebToken.decode(http_auth_header)
|
30
30
|
@decoded_auth_token
|
31
31
|
end
|
32
32
|
|
33
33
|
def http_auth_header
|
34
|
-
Rails.logger.debug "AuthorizeApiRequest: Authorization -> #{headers['Authorization']}"
|
34
|
+
Rails.logger.debug "AuthorizeApiRequest: http_auth_header - Authorization -> #{headers['Authorization']}"
|
35
35
|
if headers['Authorization'].present?
|
36
36
|
token = headers['Authorization'].split(' ').last
|
37
|
-
Rails.logger.debug "AuthorizeApiRequest: token -> #{token}"
|
37
|
+
Rails.logger.debug "AuthorizeApiRequest: http_auth_header - token -> #{token}"
|
38
38
|
return token
|
39
39
|
else
|
40
40
|
errors.add(:token, "Missing token")
|
@@ -61,15 +61,18 @@ class Api::V2::InfoController < Api::V2::ApplicationController
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def compute_type(model, key)
|
64
|
+
Rails.logger.debug "compute_type #{model} #{key}"
|
64
65
|
# if it's a file, a date or a text, then return string
|
65
66
|
instance = model.new
|
66
67
|
# If it's a method, it is a peculiar case, in which we have to return "object" and additionalProperties: true
|
67
68
|
return "method" if model.methods.include?(:json_attrs) && model.json_attrs && model.json_attrs.include?(:methods) && model.json_attrs[:methods].include?(key.to_sym)
|
68
69
|
# If it's not the case of a method, then it's a field
|
69
70
|
method_class = instance.send(key).class.to_s
|
71
|
+
Rails.logger.debug "compute_type #{model} #{key} #{method_class}"
|
70
72
|
method_key = model.columns_hash[key]
|
71
73
|
|
72
74
|
# Not columns
|
75
|
+
return nil if method_key.nil?
|
73
76
|
return "object" if method_class == "ActiveStorage::Attached::One"
|
74
77
|
return "array" if method_class == "ActiveStorage::Attached::Many" || method_class == "Array" || method_class.ends_with?("Array") || method_class.ends_with?("Collection") || method_class.ends_with?("Relation") || method_class.ends_with?("Set") || method_class.ends_with?("List") || method_class.ends_with?("Queue") || method_class.ends_with?("Stack") || method_class.ends_with?("ActiveRecord_Associations_CollectionProxy")
|
75
78
|
|
@@ -132,7 +135,7 @@ class Api::V2::InfoController < Api::V2::ApplicationController
|
|
132
135
|
[k, { "type": "array", "items": { "type": "object", "properties": properties } }] rescue nil
|
133
136
|
else
|
134
137
|
[k, { "type": type }]
|
135
|
-
end
|
138
|
+
end unless type.blank?
|
136
139
|
end.compact.to_h
|
137
140
|
end
|
138
141
|
|
data/config/routes.rb
CHANGED
data/lib/json_web_token.rb
CHANGED
@@ -10,11 +10,12 @@ class JsonWebToken
|
|
10
10
|
|
11
11
|
def decode(token)
|
12
12
|
# Check if the passed token is present and valid into the UsedToken
|
13
|
-
raise "Token is invalidated by new login"
|
13
|
+
raise "Token is invalidated by new login" if !UsedToken.exists?(token: token, is_valid: true) && ENV["ALLOW_MULTISESSIONS"] == "false"
|
14
14
|
body = ::JWT.decode(token, ::Rails.application.credentials.dig(:secret_key_base).presence||ENV["SECRET_KEY_BASE"])[0]
|
15
|
+
Rails.logger.debug "JsonWebToken: decode -> body -> #{body}"
|
15
16
|
::HashWithIndifferentAccess.new body
|
16
|
-
rescue
|
17
|
-
|
17
|
+
# rescue
|
18
|
+
# nil
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|