Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

anphung/go-auth-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-auth-cache

Description

This middleware assigns value "true" to header "go-auth-cache-Authenticated" to http.ResponseWriter if http.Request's header "Authorization" in this middleware's cache (cache hit). Assigns "false" otherwise.

One efficient usage is for Basic authentication. We use this middleware to know if the http.Request already authenticated in the past, avoid overhead of authenticating the same user over and over again.

Before exists, this middleware cache the request if http.ResponseWriter's header "go-auth-cache-Authenticated" is set to "cache".

Usage:

authCacheMiddleware := cache.NewDefault()

We then plug authCacheMiddleware in front of any middleware. Check this for example.

Note: Any of the following middleware of this middleware has to explicitly set http.ResponseWriter's header "go-auth-cache-Authenticated" to:

  • "cache", if it want the request to be cached.
  • don't set, do nothing.

About

Cache Basic authentication.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages