vestauth 0.4.0 → 0.5.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: 8c89e42127df034e314cc6b11c576f76165c3ba8f99b0b6540eb9aee92e77541
4
- data.tar.gz: 74d41456361216beb075c498b1cb6f1f8f1cf381628d64303ab5e8af2daf76cd
3
+ metadata.gz: c6b8f1d4a5090fe9722110044d32e179747140a59095bfa8cb204da5181d320f
4
+ data.tar.gz: e5fa5304418ee9327a68828e670c6b32e8df582d3279f85b1babe9158af7608f
5
5
  SHA512:
6
- metadata.gz: '098e54f2851e34efa9b82d5a5d0afc0f5d531c27f23cb41384764f1a10f6238e232ca14971e98df38dea2ba48f41db2f5946b5c3b8900ab0e8c36ecf322851f2'
7
- data.tar.gz: 44a27df536ced66a434eaf705caa617cb545f0883f979fdf8574b7b23544a109870873848ee3c6e802931a6b744d6af325cacaa4bbbf87ea243f0896e37a8dd9
6
+ metadata.gz: 1f2caff1c291833e5e980181bc80541c5d90190b3863b97fce823c66ebb8f19272c098a9bf2d04511375c0af91d25808de1ba9fecccbe8bb49fe7f9c260f1bb6
7
+ data.tar.gz: d840d82fc9ce7167e112cfd78b62e98090fcd3085d0c51f7e0390eb7746556ea2071fb0b7489f0ae51c19d8e81996f5f7062a255726d9926f43a20a71d8d1bac
@@ -4,11 +4,11 @@ module Vestauth
4
4
  module Agent
5
5
  module_function
6
6
 
7
- def headers(http_method:, uri:, private_key:, id:)
7
+ def headers(http_method:, uri:, private_jwk:, id:)
8
8
  vestauth_binary.agent_headers(
9
9
  http_method: http_method,
10
10
  uri: uri,
11
- private_key: private_key,
11
+ private_jwk: private_jwk,
12
12
  id: id
13
13
  )
14
14
  end
@@ -27,8 +27,8 @@ module Vestauth
27
27
  run_json_command(command)
28
28
  end
29
29
 
30
- def agent_headers(http_method:, uri:, private_key:, id:)
31
- private_jwk = serialize_json_arg(private_key, name: "private_key")
30
+ def agent_headers(http_method:, uri:, private_jwk:, id:)
31
+ private_jwk = serialize_json_arg(private_jwk, name: "private_jwk")
32
32
 
33
33
  command = [
34
34
  @executable,
@@ -45,8 +45,8 @@ module Vestauth
45
45
  run_json_command(command)
46
46
  end
47
47
 
48
- def primitives_verify(http_method:, uri:, signature_header:, signature_input_header:, public_key:)
49
- public_jwk = serialize_json_arg(public_key, name: "public_key")
48
+ def primitives_verify(http_method:, uri:, signature_header:, signature_input_header:, public_jwk:)
49
+ public_jwk = serialize_json_arg(public_jwk, name: "public_jwk")
50
50
 
51
51
  command = [
52
52
  @executable,
@@ -78,11 +78,30 @@ module Vestauth
78
78
 
79
79
  def serialize_json_arg(value, name:)
80
80
  return value if value.is_a?(String)
81
+
81
82
  return JSON.generate(value) if value.is_a?(Hash) || value.is_a?(Array)
82
- return JSON.generate(value.to_h) if value.respond_to?(:to_h)
83
+
84
+ if value.respond_to?(:to_h)
85
+ json = serialize_json_arg_from_to_h(value)
86
+ return json unless json.nil?
87
+ end
83
88
  return JSON.generate(value.as_json) if value.respond_to?(:as_json)
84
89
 
85
90
  raise ArgumentError, "#{name} must be a JSON string, Hash/Array, or object responding to #to_h"
86
91
  end
92
+
93
+ def serialize_json_arg_from_to_h(value)
94
+ JSON.generate(value.to_h)
95
+ rescue StandardError => e
96
+ raise unless action_controller_unfiltered_parameters?(e)
97
+
98
+ nil
99
+ end
100
+
101
+ def action_controller_unfiltered_parameters?(error)
102
+ error.instance_of?(Object.const_get("ActionController::UnfilteredParameters"))
103
+ rescue NameError
104
+ false
105
+ end
87
106
  end
88
107
  end
@@ -4,13 +4,13 @@ module Vestauth
4
4
  module Primitives
5
5
  module_function
6
6
 
7
- def verify(http_method:, uri:, signature_header:, signature_input_header:, public_key:)
7
+ def verify(http_method:, uri:, signature_header:, signature_input_header:, public_jwk:)
8
8
  vestauth_binary.primitives_verify(
9
9
  http_method: http_method,
10
10
  uri: uri,
11
11
  signature_header: signature_header,
12
12
  signature_input_header: signature_input_header,
13
- public_key: public_key
13
+ public_jwk: public_jwk
14
14
  )
15
15
  end
16
16
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vestauth
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vestauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - motdotla