Skip to content

Commit e511331

Browse files
committed
disable caching on authorization redirect
issue similar to https://github.com/zmartzone/mod_auth_openidc/issues/321 Signed-off-by: Stefan Bodewig <stefan.bodewig@innoq.com>
1 parent c76ca52 commit e511331

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
05/24/2018
2+
- add Cache-Control no-cache header to authorization requests to avoid replays of state/nonce;
3+
see https://github.com/zmartzone/mod_auth_openidc/issues/321
4+
15
04/28/2018
26
- release 1.5.4
37

lib/resty/openidc.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ local function openidc_authorize(opts, session, target_url, prompt)
310310
session:save()
311311

312312
-- redirect to the /authorization endpoint
313+
ngx.header["Cache-Control"] = "no-cache, no-store, max-age=0"
313314
return ngx.redirect(openidc_combine_uri(opts.discovery.authorization_endpoint, params))
314315
end
315316

tests/spec/redirect_to_op_spec.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ describe("when accessing the protected resource without token", function()
1313
assert.are.equals(302, status)
1414
assert.truthy(string.match(headers["location"], "http://127.0.0.1/authorize%?.*client_id=client_id.*"))
1515
end)
16+
it("HTTP Caching is disabled", function()
17+
assert.are.equals("no-cache, no-store, max-age=0", headers["cache-control"])
18+
end)
1619
it("requests the authorization code grant flow", function()
1720
assert.truthy(string.match(headers["location"], ".*response_type=code.*"))
1821
end)

0 commit comments

Comments
 (0)