Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hash/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down