Skip to content

Commit 572b566

Browse files
committed
Prevent cache of qr code
1 parent e62387f commit 572b566

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6+
## [3.0.4] - 2021-04-27
7+
8+
### Changed
9+
10+
- Change qrcode endpoint for totp to try to prevent caching
11+
612
## [3.0.3] - 2021-02-14
713

814
### Fixed

otp/twofactor/totp2fa/totp.go

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ func (t *TOTP) GetQRCode(w http.ResponseWriter, r *http.Request) error {
221221
return errors.Wrap(err, "failed to encode qr code to png")
222222
}
223223

224+
w.Header().Set("Cache-Control", "no-store")
224225
w.Header().Set("Content-Type", "image/png")
225226
w.WriteHeader(http.StatusOK)
226227
_, err = io.Copy(w, buf)

otp/twofactor/totp2fa/totp_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ func TestGetQRCode(t *testing.T) {
256256
if got := wr.Header().Get("Content-Type"); got != "image/png" {
257257
t.Error("content type wrong:", got)
258258
}
259+
if got := wr.Header().Get("Cache-Control"); got != "no-store" {
260+
t.Error("cache control header wrong:", got)
261+
}
259262
if wr.Body.Len() == 0 {
260263
t.Error("body should have been sizable")
261264
}

0 commit comments

Comments
 (0)