@@ -44,13 +44,12 @@ type LocalURLFallback struct {
4444
4545// LocalURLMapping maps a URL identifier prefix to a local file source.
4646type LocalURLMapping struct {
47- Prefix string
48- File * FileOpener
49- OCFL bool
50- AuthProbe bool
51- AuthCacheTTL time.Duration
52- AuthErrorCacheMinAge time.Duration
53- AuthCacheMaxEntries int
47+ Prefix string
48+ File * FileOpener
49+ OCFL bool
50+ AuthProbe bool
51+ AuthCacheTTL time.Duration
52+ AuthCacheMaxEntries int
5453}
5554
5655type authCacheEntry struct {
@@ -65,10 +64,9 @@ var errAuthProbeHeadUnsupported = errors.New("auth probe head unsupported")
6564type authCacheTier string
6665
6766const (
68- authCacheTierAnonymous authCacheTier = "anonymous"
69- authCacheTierAuthenticated authCacheTier = "authenticated"
70- defaultAuthErrorCacheMinAge = 5 * time .Minute
71- defaultAuthCacheMaxEntries = 4096
67+ authCacheTierAnonymous authCacheTier = "anonymous"
68+ authCacheTierAuthenticated authCacheTier = "authenticated"
69+ defaultAuthCacheMaxEntries = 4096
7270)
7371
7472// Open implements Opener.
@@ -315,7 +313,7 @@ func (l *LocalURLFallback) authorize(ctx context.Context, identifier string, map
315313 }
316314 return l .authorizeAuthenticated (ctx , identifier , mapping , headers )
317315 }
318- anonErr := l .probeCached (ctx , anonKey , identifier , nil , mapping .anonymousAuthTTL (), mapping .authErrorCacheMinAge (), mapping . authCacheMaxEntries ())
316+ anonErr := l .probeCached (ctx , anonKey , identifier , nil , mapping .anonymousAuthTTL (), mapping .authCacheMaxEntries ())
319317 if anonErr == nil || ! hasAuthHeaders (headers ) {
320318 return anonErr
321319 }
@@ -330,10 +328,10 @@ func (l *LocalURLFallback) authorizeAuthenticated(ctx context.Context, identifie
330328 if err , ok := l .cachedAuth (key ); ok {
331329 return err
332330 }
333- return l .probeCached (ctx , key , identifier , headers , mapping .authenticatedAuthTTL (), mapping .authErrorCacheMinAge (), mapping . authCacheMaxEntries ())
331+ return l .probeCached (ctx , key , identifier , headers , mapping .authenticatedAuthTTL (), mapping .authCacheMaxEntries ())
334332}
335333
336- func (l * LocalURLFallback ) probeCached (ctx context.Context , key , identifier string , headers http.Header , ttl , errorMinAge time.Duration , maxEntries int ) error {
334+ func (l * LocalURLFallback ) probeCached (ctx context.Context , key , identifier string , headers http.Header , ttl time.Duration , maxEntries int ) error {
337335 if wait , ok := l .beginAuthProbe (key ); ok {
338336 l .debug (ctx , "local url auth probe waiting on in-flight probe" , identifier , "cache_key" , redact .Hash (key ))
339337 select {
@@ -344,8 +342,8 @@ func (l *LocalURLFallback) probeCached(ctx context.Context, key, identifier stri
344342 return ctx .Err ()
345343 }
346344 }
347- respHeader , err := l .probe (ctx , identifier , headers )
348- cacheable := cacheableAuthProbeResult (err ) && cacheableAuthProbeResponse ( err , respHeader , errorMinAge , time . Now ())
345+ _ , err := l .probe (ctx , identifier , headers )
346+ cacheable := cacheableAuthProbeResult (err )
349347 l .debug (ctx , "local url auth probe completed" , identifier , "cache_key" , redact .Hash (key ), "cacheable" , cacheable , "ttl" , ttl .String (), "err" , err )
350348 if ttl > 0 && cacheable {
351349 l .storeAuth (key , authCacheScope (key ), identifier , err , ttl , maxEntries )
@@ -388,18 +386,7 @@ func hasAuthHeaders(headers http.Header) bool {
388386}
389387
390388func cacheableAuthProbeResult (err error ) bool {
391- return err == nil || errors .Is (err , ErrForbidden ) || errors .Is (err , ErrNotFound )
392- }
393-
394- func cacheableAuthProbeResponse (err error , header http.Header , errorMinAge time.Duration , now time.Time ) bool {
395- if err == nil || (! errors .Is (err , ErrForbidden ) && ! errors .Is (err , ErrNotFound )) || errorMinAge <= 0 {
396- return true
397- }
398- modified , parseErr := http .ParseTime (header .Get ("Last-Modified" ))
399- if parseErr != nil {
400- return true
401- }
402- return ! modified .After (now .Add (- errorMinAge ))
389+ return err == nil
403390}
404391
405392func (m LocalURLMapping ) anonymousAuthTTL () time.Duration {
@@ -410,13 +397,6 @@ func (m LocalURLMapping) authenticatedAuthTTL() time.Duration {
410397 return m .AuthCacheTTL
411398}
412399
413- func (m LocalURLMapping ) authErrorCacheMinAge () time.Duration {
414- if m .AuthErrorCacheMinAge > 0 {
415- return m .AuthErrorCacheMinAge
416- }
417- return defaultAuthErrorCacheMinAge
418- }
419-
420400func (m LocalURLMapping ) authCacheMaxEntries () int {
421401 if m .AuthCacheMaxEntries > 0 {
422402 return m .AuthCacheMaxEntries
0 commit comments