Skip to content

Commit

Permalink
Compact logging payload, rename AuthorizeRequest ->
Browse files Browse the repository at this point in the history
AuthorizeCertRequest for logging clarity
  • Loading branch information
suprjinx committed Sep 18, 2024
1 parent 88ce4b3 commit 8fbc730
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions app/interactors/audit_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def log
result: result,
error: context.error&.message,
subject: context.identity&.subject,
cert_common_name: context.request&.try(:common_name)
}
cert_common_name: context.request&.try(:common_name),
kv_path: context.request&.try(:kv_path)
}.compact!
AuditLogger.new.send(level, payload)
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AuthorizeRequest
class AuthorizeCertRequest
include Interactor
include FailOnError
include AuditLogging
Expand Down
2 changes: 1 addition & 1 deletion app/interactors/issue_cert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ class IssueCert
include Interactor::Organizer
include FailOnError

organize RefreshDomain, AuthorizeRequest, ObtainCert
organize RefreshDomain, AuthorizeCertRequest, ObtainCert
end
1 change: 1 addition & 0 deletions app/lib/requests/secret_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SecretRequest

attribute :path, :string
attribute :data
alias_attribute :kv_path, :path

validates :path, presence: true
end
Expand Down
1 change: 1 addition & 0 deletions app/lib/services/vault_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def client
end

def enable_engine(mount, type)
# create the engine mount if not present already
unless client.sys.mounts.key?(mount.to_sym)
client.sys.mount(mount, type, "#{type} secrets engine")
end
Expand Down
2 changes: 1 addition & 1 deletion test/integration/certificates_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "test_helper"

class CertificatesTest < ActionDispatch::IntegrationTest
test "#create unauthorized" do
test "#create with missing token" do
post certificates_path
assert_response :unauthorized
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "test_helper"

class AuthorizeRequestTest < ActiveSupport::TestCase
class AuthorizeCertRequestTest < ActiveSupport::TestCase
def setup
@domain = domains(:group_match)
@identity = Identity.new(subject: @domain.users_array.first)
@cr = Requests::CertIssueRequest.new(common_name: @domain.fqdn)
@interactor = AuthorizeRequest
@interactor = AuthorizeCertRequest
end

test ".call with matching owner" do
Expand Down

0 comments on commit 8fbc730

Please sign in to comment.