Skip to content

Commit

Permalink
cache: Enforce no-caching on the client side
Browse files Browse the repository at this point in the history
Adding http headers to enforce requests are not cached by the browser.
  • Loading branch information
jfrabaute authored and ajhfok committed Jul 11, 2023
1 parent c824f09 commit 7afd99f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ func (s *server) authenticate(w http.ResponseWriter, r *http.Request, promptLogi
logger := common.LoggerForRequest(r, logModuleInfo)
logger.Info("Authenticating request...")

// Enforce no caching on the browser side.
w.Header().Add("Cache-Control", "private, max-age=0, no-cache, no-store")

// Try each one of the available enabled authenticators, if none of them
// achieves to authenticate the request then userInfo will be nil and
// Authorization Code Flow will begin.
Expand Down Expand Up @@ -374,6 +377,9 @@ func (s *server) callback(w http.ResponseWriter, r *http.Request) {

logger := common.LoggerForRequest(r, logModuleInfo)

// Enforce no caching on the browser side.
w.Header().Add("Cache-Control", "private, max-age=0, no-cache, no-store")

// Get authorization code from authorization response.
var authCode = r.FormValue("code")
if len(authCode) == 0 {
Expand Down

0 comments on commit 7afd99f

Please sign in to comment.