fluent-plugin-jwt-filter 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35ca92587b5a5df39f60e20e78a3f129f47f9ea9
4
- data.tar.gz: 5ac5a446a062a7f86ea484931401430f66965d3c
3
+ metadata.gz: 1af7d2c7c4a08f9bae0730f0e62077fa214c992f
4
+ data.tar.gz: 33666b0325507dedbba84ac5ddf9f5c77c14e779
5
5
  SHA512:
6
- metadata.gz: 607e9a9bffb0992e5b619a6721a2eada310bc9b876a09db7d05d88305293d7d21312c34c089e5c43567e1f9afa5cb0720afd58c46818dd2e962f311a48810246
7
- data.tar.gz: b7046587cf304be9077a378cb0d4b9a40f1dbe6b5c52ea58d38ce8a529154a626a4cc2b8ce639fe0609a64a185ab6cefcecf4f43635466a2d00830d0a83a00d9
6
+ metadata.gz: e7c1b772d19757be80751095ab0b81596a5b701ea24f720d991ae2f500487f57e39ae5508073ed42b63e0d01a8336dd0870fa7b35f7c016ff850fffec3f71c31
7
+ data.tar.gz: 80a4f3571e1dd99b3fccfc5898837e2bbb0059dc4fbc2fb89fcc02ec6db79b2dc4d784b32ef28dcde96b12bdad0ce221a565f0ffe75a9a0331164f648d2b9424
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-jwt-filter"
7
- spec.version = "0.0.4"
7
+ spec.version = "0.0.5"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
@@ -7,13 +7,18 @@ module Fluent
7
7
  # Currently symmetric key is not supported in JSON Web Key (TODO)
8
8
  #
9
9
  # Example encrypted JSON message is as follows:
10
- # {
11
- # "protected": "eyJlbmMiOiJBMTI4R0NNIiwiYWxnIjoiUlNBMV81In0",
12
- # "encrypted_key": "P8dKW8KE5nJm7s9GDENrcSW2iNw0Fo4FqDxRwyr6JSGCPCwjc_agoEq7O8xhWX_WoRZin90ORPP1oO5_kavTIcppnRcmquxm1jhQtKk77-HN9Efo7DQf3yfgdnD7xv-M1I_rCPeHVFm33BNB6TIhCo1fUfhEUM8GjjC8PLFFwOcDUNf1vw1-WjUqMhUf-b45s6CHhYdpDqzs7GYuovDo0LMeFeBSc4Xntw_vWPMeHxsuVyuZpDHUQm-dX5wnmQ4UhZPzEhkkVJw1oz2uTMjcl6mi1bucKGy1zNaGN-JEhg5_2QgijqTxRtJgOBlVtHLJ5HABT4tI6-v06M3dPryz5w",
13
- # "iv": "xYk2s_39pHvLBZy3",
14
- # "ciphertext": "taCQAMBZtKgQfh5LaWs",
15
- # "tag": "nbWyhG82A-eCJMvdhbrSJw"
10
+ # {"jwe_encrypted":
11
+ # {
12
+ # "protected": "eyJlbmMiOiJBMTI4R0NNIiwiYWxnIjoiUlNBMV81In0",
13
+ # "encrypted_key": "P8dKW8KE5nJm7s9GDENrcSW2iNw0Fo4FqDxRwyr6JSGCPCwjc_agoEq7O8xhWX_WoRZin90ORPP1oO5_kavTIcppnRcmquxm1jhQtKk77-HN9Efo7DQf3yfgdnD7xv-M1I_rCPeHVFm33BNB6TIhCo1fUfhEUM8GjjC8PLFFwOcDUNf1vw1-WjUqMhUf-b45s6CHhYdpDqzs7GYuovDo0LMeFeBSc4Xntw_vWPMeHxsuVyuZpDHUQm-dX5wnmQ4UhZPzEhkkVJw1oz2uTMjcl6mi1bucKGy1zNaGN-JEhg5_2QgijqTxRtJgOBlVtHLJ5HABT4tI6-v06M3dPryz5w",
14
+ # "iv": "xYk2s_39pHvLBZy3",
15
+ # "ciphertext": "taCQAMBZtKgQfh5LaWs",
16
+ # "tag": "nbWyhG82A-eCJMvdhbrSJw"
17
+ # }
16
18
  # }
19
+ #
20
+ # If some attributes added to the contents during the transfer,
21
+ # the decrypted contents are merged into the modified hash.
17
22
  class JwtFilter < Filter
18
23
  # Register this filter as "jwt"
19
24
  Plugin.register_filter("jwt", self)
@@ -79,7 +84,9 @@ module Fluent
79
84
  # encryption
80
85
  jwe.encrypt!(@jwk_pub.to_key)
81
86
  # output the result in JSON format
82
- jwe.as_json
87
+ output = {jwe_encrypted: jwe.as_json}
88
+ $log.debug output
89
+ output
83
90
  rescue Exception => e
84
91
  $log.error "Error", :error => e.to_s
85
92
  $log.debug_backtrace(e.backtrace)
@@ -89,9 +96,12 @@ module Fluent
89
96
  def decrypt(record)
90
97
  begin
91
98
  # decrypt JSON format cipher data
92
- jwe_dec = JSON::JWE.decode_json_serialized(record, @jwk.to_key)
99
+ jwe_dec = JSON::JWE.decode_json_serialized(record["jwe_encrypted"], @jwk.to_key)
93
100
  $log.debug jwe_dec.plain_text
94
- JSON.parse(jwe_dec.plain_text)
101
+ # merge decrypted contents into original contents without jwe_encrypted
102
+ output = record.select {|k| k != "jwe_encrypted"}.merge(JSON.parse(jwe_dec.plain_text))
103
+ $log.debug output
104
+ output
95
105
  rescue JSON::ParserError => e
96
106
  $log.error "Message parse error", :error => e.to_s
97
107
  $log.debug_backtrace(e.backtrace)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-jwt-filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama