From dd44fe9b2a0ee939b33c06ab4c29cafc334fe32a Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Wed, 28 May 2025 12:29:09 +0000 Subject: [PATCH] Add option to retrive keyid in use Signed-off-by: Prabhjot Singh Sethi --- hash/validator.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hash/validator.go b/hash/validator.go index ac54191..39bd371 100644 --- a/hash/validator.go +++ b/hash/validator.go @@ -61,6 +61,9 @@ type Validator interface { // Validate checks the HMAC signature, timestamp, and expiration of the request. // Returns true if valid, false and an error otherwise. Validate(r *http.Request, secret string) (bool, error) + + // Check if Api Key is in use + GetKeyId(r *http.Request) string } // validator is a concrete implementation of the Validator interface. @@ -129,6 +132,10 @@ func (v *validator) Validate(r *http.Request, secret string) (bool, error) { return true, nil } +func (v *validator) GetKeyId(r *http.Request) string { + return r.Header.Get("x-api-key-id") +} + // NewValidator creates a new Validator instance for validating HTTP requests. // // Parameters: