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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a287c014efd45c5877ecc26d5abc78e53682abcb006e6641fe38b087d1c99d89
4
- data.tar.gz: '088277a7856122dfccfd4270a89224a950a97264e4933734e9e2bbe845c436f6'
3
+ metadata.gz: a7f7a6e80d29d9df59d7be8485a91a735e87e1a1b801d3bd7ff4ed9080e8b358
4
+ data.tar.gz: c43e0a024dfa83b81ab4decd4522d55c84ca80e5c280d1f2c01256dfb11f249c
5
5
  SHA512:
6
- metadata.gz: '03881bc2bc10c0cb61b981415242c476f621578b89cc3827fb61255dc56c5276bb493b30496718e4774387879913519e3195f4e35299c1b8e9d1eb3fea6f3cf9'
7
- data.tar.gz: 8daa6997703f0be55eb81a8d1ee6adae87e4a0234acd5e78c625c078f9f23a208198bc4e1741febbb81ea5eca1c9d5cfa2c51acb4b14bd731632a1e8ddf832df
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 = auth_token.present? ? JWT.decode(auth_token.gsub('Bearer ', ''), nil, false) : {}
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
@@ -3,7 +3,7 @@
3
3
  module Yes
4
4
  module Command
5
5
  module Api
6
- VERSION = '2.4.5'
6
+ VERSION = '2.5.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yes-command-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.5
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Ritsche