Skip to content

Commit

Permalink
Working on feature shaj13#31, revoke method ldap
Browse files Browse the repository at this point in the history
  • Loading branch information
guisithos committed Oct 30, 2024
1 parent c25c80f commit 5766e26
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions auth/strategies/ldap/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,24 @@ func New(cfg *Config, opts ...auth.Option) auth.Strategy {
return basic.New(fn, opts...)
}

// NewCached return strategy authenticate request using LDAP.
// The returned strategy, caches the authentication decision.
// New is similar to Basic.NewCached().
// Add new type
type CachedLDAP struct {
auth.Strategy
cache auth.Cache
}

// Implement token.Revokable interface
func (c *CachedLDAP) Revoke(hash string) error {
c.cache.Delete(hash)
return nil
}

// Update NewCached to return our new type
func NewCached(cfg *Config, c auth.Cache, opts ...auth.Option) auth.Strategy {
fn := GetAuthenticateFunc(cfg, opts...)
return basic.NewCached(fn, c, opts...)
strategy := basic.NewCached(fn, c, opts...)
return &CachedLDAP{
Strategy: strategy,
cache: c,
}
}

0 comments on commit 5766e26

Please sign in to comment.