Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-strigo committed Sep 8, 2023
1 parent 83ff12f commit 007fc97
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 0 additions & 2 deletions cache.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package traefik_auth_middleware

import (
"fmt"
"sync"
"time"
)
Expand Down Expand Up @@ -37,7 +36,6 @@ func (c *Cache) ClearExpired() {
c.Lock()
for k, v := range c.dirty {
if v.ExpirationTime.Before(time.Now()) {
fmt.Println("deleting")
delete(c.dirty, k)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ type Plugin struct {
func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error) {
// Start cache clearing cycle to remove any expired tokens
go func() {
for {
time.Sleep(CACHE_CLEAR_CYCLE_HRS * time.Hour)
for range time.Tick(CACHE_CLEAR_CYCLE_HRS * time.Hour) {
tokenCache.ClearExpired()
}
}()
Expand All @@ -59,7 +58,7 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
func (p *Plugin) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
cfjwt := req.Header.Get(CF_HEADER)
if cfjwt == "" {
p.logger.Println("No Cf-Access-Jwt-Assertion header found")
p.logger.Printf("Header %v not found\n", CF_HEADER)
p.next.ServeHTTP(rw, req)
return
}
Expand Down

0 comments on commit 007fc97

Please sign in to comment.