Skip to content

Commit

Permalink
fix: add missing interface validation for structs that implements Aut…
Browse files Browse the repository at this point in the history
…henticationValidation in authenticator_filters.go (#40)
  • Loading branch information
navidnabavi authored Feb 24, 2024
1 parent afeaeef commit 9eeaab7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/auth/authenticator_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type AuthenticationValidation interface {

type AuthenticatorPriorityValidation struct{}

var _ AuthenticationValidation = (*AuthenticatorPriorityValidation)(nil)

func (apt *AuthenticatorPriorityValidation) Validate(ac *AccessTokensCacheEntry,
wsvc *WebservicesCacheEntry, _ *Request) (CerberusReason, CerberusExtraHeaders) {

Expand All @@ -32,6 +34,8 @@ func (apt *AuthenticatorPriorityValidation) Validate(ac *AccessTokensCacheEntry,

type AuthenticationIPValidation struct{}

var _ AuthenticationValidation = (*AuthenticationIPValidation)(nil)

// getIPListFromRequest extract IP addresses from request and it's headers
func getIPListFromRequest(request *http.Request) (CerberusReason, []string) {
ipList := make([]string, 0)
Expand Down Expand Up @@ -107,6 +111,8 @@ func checkIP(ips []string, ipAllowList []string) (bool, error) {
// AuthenticationDomainValidation validates for domain definitions
type AuthenticationDomainValidation struct{}

var _ AuthenticationValidation = (*AuthenticationDomainValidation)(nil)

// Validate checks domain restrictions
func (adv *AuthenticationDomainValidation) Validate(ac *AccessTokensCacheEntry,
wsvc *WebservicesCacheEntry, request *Request) (CerberusReason, CerberusExtraHeaders) {
Expand Down Expand Up @@ -149,6 +155,8 @@ func CheckDomain(domain string, domainAllowedList []string) (bool, error) {
// AuthenticationTokenAccessValidation check for token and webservice access
type AuthenticationTokenAccessValidation struct{}

var _ AuthenticationValidation = (*AuthenticationTokenAccessValidation)(nil)

// Validate checks token and webservice access
func (adv *AuthenticationTokenAccessValidation) Validate(ac *AccessTokensCacheEntry,
wsvc *WebservicesCacheEntry, request *Request) (CerberusReason, CerberusExtraHeaders) {
Expand Down

0 comments on commit 9eeaab7

Please sign in to comment.