From 41bc9251fd872470e177bdda534f669e8622e7a6 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Wed, 25 Feb 2026 17:35:02 -0800 Subject: [PATCH 1/4] rename `provider` to `tool` --- README.md | 2 +- lib/vestauth.rb | 6 +++++- spec/vestauth_spec.rb | 9 +++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 78f81e5..72dc904 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ class ApplicationController < ActionController::Base private def verify_agent! - @current_agent ||= Vestauth.provider.verify(http_method: request.method, uri: request.original_url, headers: request.headers) + @current_agent ||= Vestauth.tool.verify(http_method: request.method, uri: request.original_url, headers: request.headers) rescue => e render json: { error: { status: 401, code: 401, message: e.message } }, status: 401 end diff --git a/lib/vestauth.rb b/lib/vestauth.rb index 6838801..30b295b 100644 --- a/lib/vestauth.rb +++ b/lib/vestauth.rb @@ -8,10 +8,14 @@ module Vestauth class Error < StandardError; end - def self.provider + def self.tool Provider end + class << self + alias provider tool + end + def self.agent Agent end diff --git a/spec/vestauth_spec.rb b/spec/vestauth_spec.rb index dc1958f..9d4a0c4 100644 --- a/spec/vestauth_spec.rb +++ b/spec/vestauth_spec.rb @@ -5,18 +5,19 @@ expect(Vestauth::VERSION).not_to be nil end - it "exposes namespaced provider and agent modules" do + it "exposes namespaced tool/provider and agent modules" do + expect(Vestauth.tool).to eq(Vestauth::Provider) expect(Vestauth.provider).to eq(Vestauth::Provider) expect(Vestauth.agent).to eq(Vestauth::Agent) expect(Vestauth.binary).to eq(Vestauth::Binary) end - it "delegates provider verify to binary provider_verify" do + it "delegates tool verify to binary provider_verify" do binary = instance_double(Vestauth::Binary) allow(Vestauth::Binary).to receive(:new).and_return(binary) allow(binary).to receive(:provider_verify).and_return({ "uid" => "agent-123" }) - result = Vestauth.provider.verify( + result = Vestauth.tool.verify( http_method: "GET", uri: "https://api.vestauth.com/whoami", headers: { @@ -41,7 +42,7 @@ allow(Vestauth::Binary).to receive(:new).and_return(binary) allow(binary).to receive(:provider_verify).and_return({ "success" => false }) - Vestauth.provider.verify( + Vestauth.tool.verify( http_method: "GET", uri: "https://api.vestauth.com/whoami", headers: {} From 30905415ca062acbf396c7e8f3fa5f3f1d4df176 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Wed, 25 Feb 2026 17:37:12 -0800 Subject: [PATCH 2/4] rename `provider` to `tool` --- lib/vestauth.rb | 3 ++- lib/vestauth/provider.rb | 41 +++------------------------------------ lib/vestauth/tool.rb | 42 ++++++++++++++++++++++++++++++++++++++++ spec/vestauth_spec.rb | 5 +++-- 4 files changed, 50 insertions(+), 41 deletions(-) create mode 100644 lib/vestauth/tool.rb diff --git a/lib/vestauth.rb b/lib/vestauth.rb index 30b295b..6d35759 100644 --- a/lib/vestauth.rb +++ b/lib/vestauth.rb @@ -3,13 +3,14 @@ require_relative "vestauth/version" require_relative "vestauth/agent" require_relative "vestauth/binary" +require_relative "vestauth/tool" require_relative "vestauth/provider" module Vestauth class Error < StandardError; end def self.tool - Provider + Tool end class << self diff --git a/lib/vestauth/provider.rb b/lib/vestauth/provider.rb index c89eae5..76f6315 100644 --- a/lib/vestauth/provider.rb +++ b/lib/vestauth/provider.rb @@ -1,42 +1,7 @@ # frozen_string_literal: true -module Vestauth - module Provider - module_function - - def verify(http_method:, uri:, headers:) - signature = signature_header(headers) - signature_input = signature_input_header(headers) - signature_agent = signature_agent_header(headers) - - attrs = { - http_method: http_method, - uri: uri, - signature: signature, - signature_input: signature_input, - signature_agent: signature_agent - } - vestauth_binary.provider_verify(**attrs) - end - - def vestauth_binary - Vestauth::Binary.new - end - private_class_method :vestauth_binary +require_relative "tool" - def signature_header(headers) - headers["Signature"] || headers["signature"] - end - private_class_method :signature_header - - def signature_input_header(headers) - headers["Signature-Input"] || headers["signature-input"] - end - private_class_method :signature_input_header - - def signature_agent_header(headers) - headers["Signature-Agent"] || headers["signature-agent"] - end - private_class_method :signature_agent_header - end +module Vestauth + Provider = Tool end diff --git a/lib/vestauth/tool.rb b/lib/vestauth/tool.rb new file mode 100644 index 0000000..2e1b9cd --- /dev/null +++ b/lib/vestauth/tool.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +module Vestauth + module Tool + module_function + + def verify(http_method:, uri:, headers:) + signature = signature_header(headers) + signature_input = signature_input_header(headers) + signature_agent = signature_agent_header(headers) + + attrs = { + http_method: http_method, + uri: uri, + signature: signature, + signature_input: signature_input, + signature_agent: signature_agent + } + vestauth_binary.provider_verify(**attrs) + end + + def vestauth_binary + Vestauth::Binary.new + end + private_class_method :vestauth_binary + + def signature_header(headers) + headers["Signature"] || headers["signature"] + end + private_class_method :signature_header + + def signature_input_header(headers) + headers["Signature-Input"] || headers["signature-input"] + end + private_class_method :signature_input_header + + def signature_agent_header(headers) + headers["Signature-Agent"] || headers["signature-agent"] + end + private_class_method :signature_agent_header + end +end diff --git a/spec/vestauth_spec.rb b/spec/vestauth_spec.rb index 9d4a0c4..d0df89f 100644 --- a/spec/vestauth_spec.rb +++ b/spec/vestauth_spec.rb @@ -6,8 +6,9 @@ end it "exposes namespaced tool/provider and agent modules" do - expect(Vestauth.tool).to eq(Vestauth::Provider) - expect(Vestauth.provider).to eq(Vestauth::Provider) + expect(Vestauth::Tool).to eq(Vestauth::Provider) + expect(Vestauth.tool).to eq(Vestauth::Tool) + expect(Vestauth.provider).to eq(Vestauth::Tool) expect(Vestauth.agent).to eq(Vestauth::Agent) expect(Vestauth.binary).to eq(Vestauth::Binary) end From e0d47c411dfe4d68d37ca36b0efdeae45e836d7e Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Wed, 25 Feb 2026 20:52:11 -0800 Subject: [PATCH 3/4] `tool` --- lib/vestauth/binary.rb | 4 ++-- lib/vestauth/tool.rb | 2 +- spec/binary_spec.rb | 6 +++--- spec/vestauth_spec.rb | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/vestauth/binary.rb b/lib/vestauth/binary.rb index 785acd8..5d98dc8 100644 --- a/lib/vestauth/binary.rb +++ b/lib/vestauth/binary.rb @@ -10,10 +10,10 @@ def initialize(executable: "vestauth") @executable = executable end - def provider_verify(http_method:, uri:, signature:, signature_input:, signature_agent:) + def tool_verify(http_method:, uri:, signature:, signature_input:, signature_agent:) command = [ @executable, - "provider", + "tool", "verify", http_method, uri, diff --git a/lib/vestauth/tool.rb b/lib/vestauth/tool.rb index 2e1b9cd..beeb263 100644 --- a/lib/vestauth/tool.rb +++ b/lib/vestauth/tool.rb @@ -16,7 +16,7 @@ def verify(http_method:, uri:, headers:) signature_input: signature_input, signature_agent: signature_agent } - vestauth_binary.provider_verify(**attrs) + vestauth_binary.tool_verify(**attrs) end def vestauth_binary diff --git a/spec/binary_spec.rb b/spec/binary_spec.rb index d693f6c..731e295 100644 --- a/spec/binary_spec.rb +++ b/spec/binary_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true RSpec.describe Vestauth::Binary do - describe "#provider_verify" do + describe "#tool_verify" do it "calls vestauth provider verify and parses json output" do status = instance_double(Process::Status, success?: true) binary = described_class.new @@ -10,7 +10,7 @@ include("vestauth provider verify GET https://api.vestauth.com/whoami") ).and_return(['{"uid":"agent-123"}', "", status]) - result = binary.provider_verify( + result = binary.tool_verify( http_method: "GET", uri: "https://api.vestauth.com/whoami", signature: "sig1=:abc:", @@ -28,7 +28,7 @@ allow(Open3).to receive(:capture3).and_return(["", "bad signature", status]) expect do - binary.provider_verify( + binary.tool_verify( http_method: "GET", uri: "https://api.vestauth.com/whoami", signature: "sig1=:abc:", diff --git a/spec/vestauth_spec.rb b/spec/vestauth_spec.rb index d0df89f..0f09444 100644 --- a/spec/vestauth_spec.rb +++ b/spec/vestauth_spec.rb @@ -13,10 +13,10 @@ expect(Vestauth.binary).to eq(Vestauth::Binary) end - it "delegates tool verify to binary provider_verify" do + it "delegates tool verify to binary tool_verify" do binary = instance_double(Vestauth::Binary) allow(Vestauth::Binary).to receive(:new).and_return(binary) - allow(binary).to receive(:provider_verify).and_return({ "uid" => "agent-123" }) + allow(binary).to receive(:tool_verify).and_return({ "uid" => "agent-123" }) result = Vestauth.tool.verify( http_method: "GET", @@ -28,7 +28,7 @@ } ) - expect(binary).to have_received(:provider_verify).with( + expect(binary).to have_received(:tool_verify).with( http_method: "GET", uri: "https://api.vestauth.com/whoami", signature: "sig1=:abc:", @@ -41,7 +41,7 @@ it "passes through missing headers and lets binary verify fail if needed" do binary = instance_double(Vestauth::Binary) allow(Vestauth::Binary).to receive(:new).and_return(binary) - allow(binary).to receive(:provider_verify).and_return({ "success" => false }) + allow(binary).to receive(:tool_verify).and_return({ "success" => false }) Vestauth.tool.verify( http_method: "GET", @@ -49,7 +49,7 @@ headers: {} ) - expect(binary).to have_received(:provider_verify).with( + expect(binary).to have_received(:tool_verify).with( http_method: "GET", uri: "https://api.vestauth.com/whoami", signature: nil, From ae7a5d2767fa55e3e03e5c900e2a08c1cb751e80 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Wed, 25 Feb 2026 20:53:39 -0800 Subject: [PATCH 4/4] patch spec --- spec/binary_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/binary_spec.rb b/spec/binary_spec.rb index 731e295..d757495 100644 --- a/spec/binary_spec.rb +++ b/spec/binary_spec.rb @@ -2,12 +2,12 @@ RSpec.describe Vestauth::Binary do describe "#tool_verify" do - it "calls vestauth provider verify and parses json output" do + it "calls vestauth tool verify and parses json output" do status = instance_double(Process::Status, success?: true) binary = described_class.new expect(Open3).to receive(:capture3).with( - include("vestauth provider verify GET https://api.vestauth.com/whoami") + include("vestauth tool verify GET https://api.vestauth.com/whoami") ).and_return(['{"uid":"agent-123"}', "", status]) result = binary.tool_verify(