vestauth 0.3.0 → 0.4.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/lib/vestauth/agent.rb +15 -0
- data/lib/vestauth/binary.rb +49 -3
- data/lib/vestauth/primitives.rb +22 -0
- data/lib/vestauth/version.rb +1 -1
- data/lib/vestauth.rb +7 -2
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c89e42127df034e314cc6b11c576f76165c3ba8f99b0b6540eb9aee92e77541
|
|
4
|
+
data.tar.gz: 74d41456361216beb075c498b1cb6f1f8f1cf381628d64303ab5e8af2daf76cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '098e54f2851e34efa9b82d5a5d0afc0f5d531c27f23cb41384764f1a10f6238e232ca14971e98df38dea2ba48f41db2f5946b5c3b8900ab0e8c36ecf322851f2'
|
|
7
|
+
data.tar.gz: 44a27df536ced66a434eaf705caa617cb545f0883f979fdf8574b7b23544a109870873848ee3c6e802931a6b744d6af325cacaa4bbbf87ea243f0896e37a8dd9
|
data/lib/vestauth/agent.rb
CHANGED
|
@@ -2,5 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
module Vestauth
|
|
4
4
|
module Agent
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def headers(http_method:, uri:, private_key:, id:)
|
|
8
|
+
vestauth_binary.agent_headers(
|
|
9
|
+
http_method: http_method,
|
|
10
|
+
uri: uri,
|
|
11
|
+
private_key: private_key,
|
|
12
|
+
id: id
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def vestauth_binary
|
|
17
|
+
Vestauth::Binary.new
|
|
18
|
+
end
|
|
19
|
+
private_class_method :vestauth_binary
|
|
5
20
|
end
|
|
6
21
|
end
|
data/lib/vestauth/binary.rb
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
4
|
require "open3"
|
|
5
|
-
require "shellwords"
|
|
6
5
|
|
|
7
6
|
module Vestauth
|
|
8
7
|
class Binary
|
|
@@ -28,15 +27,62 @@ module Vestauth
|
|
|
28
27
|
run_json_command(command)
|
|
29
28
|
end
|
|
30
29
|
|
|
30
|
+
def agent_headers(http_method:, uri:, private_key:, id:)
|
|
31
|
+
private_jwk = serialize_json_arg(private_key, name: "private_key")
|
|
32
|
+
|
|
33
|
+
command = [
|
|
34
|
+
@executable,
|
|
35
|
+
"agent",
|
|
36
|
+
"headers",
|
|
37
|
+
http_method,
|
|
38
|
+
uri,
|
|
39
|
+
"--private-jwk",
|
|
40
|
+
private_jwk,
|
|
41
|
+
"--uid",
|
|
42
|
+
id
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
run_json_command(command)
|
|
46
|
+
end
|
|
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")
|
|
50
|
+
|
|
51
|
+
command = [
|
|
52
|
+
@executable,
|
|
53
|
+
"primitives",
|
|
54
|
+
"verify",
|
|
55
|
+
http_method,
|
|
56
|
+
uri,
|
|
57
|
+
"--signature",
|
|
58
|
+
signature_header,
|
|
59
|
+
"--signature-input",
|
|
60
|
+
signature_input_header,
|
|
61
|
+
"--public-jwk",
|
|
62
|
+
public_jwk
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
run_json_command(command)
|
|
66
|
+
end
|
|
67
|
+
|
|
31
68
|
private
|
|
32
69
|
|
|
33
70
|
def run_json_command(command_args)
|
|
34
|
-
|
|
35
|
-
stdout, stderr, status = Open3.capture3(
|
|
71
|
+
argv = command_args.map { |arg| arg.nil? ? "" : arg.to_s }
|
|
72
|
+
stdout, stderr, status = Open3.capture3(*argv)
|
|
36
73
|
|
|
37
74
|
raise Vestauth::Error, (stderr.to_s.strip.empty? ? stdout : stderr) unless status.success?
|
|
38
75
|
|
|
39
76
|
JSON.parse(stdout)
|
|
40
77
|
end
|
|
78
|
+
|
|
79
|
+
def serialize_json_arg(value, name:)
|
|
80
|
+
return value if value.is_a?(String)
|
|
81
|
+
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
|
+
return JSON.generate(value.as_json) if value.respond_to?(:as_json)
|
|
84
|
+
|
|
85
|
+
raise ArgumentError, "#{name} must be a JSON string, Hash/Array, or object responding to #to_h"
|
|
86
|
+
end
|
|
41
87
|
end
|
|
42
88
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Vestauth
|
|
4
|
+
module Primitives
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def verify(http_method:, uri:, signature_header:, signature_input_header:, public_key:)
|
|
8
|
+
vestauth_binary.primitives_verify(
|
|
9
|
+
http_method: http_method,
|
|
10
|
+
uri: uri,
|
|
11
|
+
signature_header: signature_header,
|
|
12
|
+
signature_input_header: signature_input_header,
|
|
13
|
+
public_key: public_key
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def vestauth_binary
|
|
18
|
+
Vestauth::Binary.new
|
|
19
|
+
end
|
|
20
|
+
private_class_method :vestauth_binary
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/vestauth/version.rb
CHANGED
data/lib/vestauth.rb
CHANGED
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
require_relative "vestauth/version"
|
|
4
4
|
require_relative "vestauth/agent"
|
|
5
5
|
require_relative "vestauth/binary"
|
|
6
|
+
require_relative "vestauth/primitives"
|
|
6
7
|
require_relative "vestauth/tool"
|
|
7
8
|
require_relative "vestauth/provider"
|
|
8
9
|
|
|
9
10
|
module Vestauth
|
|
10
11
|
class Error < StandardError; end
|
|
11
12
|
|
|
13
|
+
def self.agent
|
|
14
|
+
Agent
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
def self.tool
|
|
13
18
|
Tool
|
|
14
19
|
end
|
|
@@ -17,8 +22,8 @@ module Vestauth
|
|
|
17
22
|
alias provider tool
|
|
18
23
|
end
|
|
19
24
|
|
|
20
|
-
def self.
|
|
21
|
-
|
|
25
|
+
def self.primitives
|
|
26
|
+
Primitives
|
|
22
27
|
end
|
|
23
28
|
|
|
24
29
|
def self.binary
|
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
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- motdotla
|
|
@@ -25,6 +25,7 @@ files:
|
|
|
25
25
|
- lib/vestauth.rb
|
|
26
26
|
- lib/vestauth/agent.rb
|
|
27
27
|
- lib/vestauth/binary.rb
|
|
28
|
+
- lib/vestauth/primitives.rb
|
|
28
29
|
- lib/vestauth/provider.rb
|
|
29
30
|
- lib/vestauth/tool.rb
|
|
30
31
|
- lib/vestauth/version.rb
|