yes-command-api 2.4.5 → 2.5.0
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/yes/command/api/v1/commands_controller.rb +1 -8
- data/config/routes.rb +15 -1
- data/lib/yes/command/api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7f7a6e80d29d9df59d7be8485a91a735e87e1a1b801d3bd7ff4ed9080e8b358
|
|
4
|
+
data.tar.gz: c43e0a024dfa83b81ab4decd4522d55c84ca80e5c280d1f2c01256dfb11f249c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 27083716af18762a8b9c52bd3e3ea49da34e41efffc7d7638073f1ce302ba655e4453b43e7bed0af974678deca4e22c259c3be73a4afdf2e8393fb5abea117ed
|
|
7
|
+
data.tar.gz: 015f37e0d21331696c40868458ea5767f6e01f30e5028570af23ac6981d9a7ce1f9a7f2a2103cb5bef682cd5ea9bd573c273354d1717ee8962a78cc77bdf4cd7
|
|
@@ -68,20 +68,13 @@ module Yes
|
|
|
68
68
|
raise Yes::Core::AuthenticationError, 'No auth adapter configured. Set Yes::Core.configuration.auth_adapter.' unless adapter
|
|
69
69
|
|
|
70
70
|
@auth_data = adapter.authenticate(request)
|
|
71
|
-
rescue *auth_error_classes => e
|
|
71
|
+
rescue *Yes::Core.configuration.auth_error_classes => e
|
|
72
72
|
auth_error_response(e)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
# @return [Hash] the authentication data
|
|
76
76
|
attr_reader :auth_data
|
|
77
77
|
|
|
78
|
-
# Returns the error classes defined by the auth adapter.
|
|
79
|
-
#
|
|
80
|
-
# @return [Array<Class>] auth error classes
|
|
81
|
-
def auth_error_classes
|
|
82
|
-
Yes::Core.configuration.auth_adapter&.error_classes || []
|
|
83
|
-
end
|
|
84
|
-
|
|
85
78
|
def perform_inline?
|
|
86
79
|
return false if params[:async] == 'true'
|
|
87
80
|
return true if params[:async] == 'false'
|
data/config/routes.rb
CHANGED
|
@@ -37,13 +37,27 @@ module Yes
|
|
|
37
37
|
request.body.rewind
|
|
38
38
|
|
|
39
39
|
auth_token = env['HTTP_AUTHORIZATION'] || ''
|
|
40
|
-
auth_data =
|
|
40
|
+
auth_data = unverified_auth_data(auth_token)
|
|
41
41
|
{
|
|
42
42
|
auth_token:,
|
|
43
43
|
auth_data: auth_data.to_json,
|
|
44
44
|
params:
|
|
45
45
|
}.stringify_keys
|
|
46
46
|
end
|
|
47
|
+
|
|
48
|
+
# Decodes the bearer token without verifying it, only to enrich the span. A missing or
|
|
49
|
+
# undecodable token yields an empty result: span enrichment must never decide the outcome
|
|
50
|
+
# of the request, the controller answers with 401 for such tokens.
|
|
51
|
+
#
|
|
52
|
+
# @param auth_token [String] the raw Authorization header value (may be empty)
|
|
53
|
+
# @return [Array<Hash>, Hash] the decoded JWT payload and header, or an empty hash
|
|
54
|
+
def unverified_auth_data(auth_token)
|
|
55
|
+
return {} if auth_token.blank?
|
|
56
|
+
|
|
57
|
+
JWT.decode(auth_token.gsub('Bearer ', ''), nil, false)
|
|
58
|
+
rescue JWT::DecodeError
|
|
59
|
+
{}
|
|
60
|
+
end
|
|
47
61
|
end
|
|
48
62
|
end
|
|
49
63
|
end
|