Skip to content

Commit 4f6c07b

Browse files
authored
Merge pull request #70 from a-p-o/patch-1
Add Cache-Control and Pragma headers to Access Token responses
2 parents f5755fa + 98eda16 commit 4f6c07b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

oauth2-server-core/src/main/java/nl/myndocs/oauth2/grant/CallRouterDefault.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ fun GrantingCall.grantPassword() = granter("password") {
2121
)
2222
)
2323

24+
callContext.respondHeader("Cache-Control", "no-store")
25+
callContext.respondHeader("Pragma", "no-cache")
2426
callContext.respondJson(accessTokenResponder.createResponse(accessToken))
2527
}
2628

@@ -31,6 +33,8 @@ fun GrantingCall.grantClientCredentials() = granter("client_credentials") {
3133
callContext.formParameters["scope"]
3234
))
3335

36+
callContext.respondHeader("Cache-Control", "no-store")
37+
callContext.respondHeader("Pragma", "no-cache")
3438
callContext.respondJson(accessTokenResponder.createResponse(accessToken))
3539
}
3640

@@ -43,6 +47,8 @@ fun GrantingCall.grantRefreshToken() = granter("refresh_token") {
4347
)
4448
)
4549

50+
callContext.respondHeader("Cache-Control", "no-store")
51+
callContext.respondHeader("Pragma", "no-cache")
4652
callContext.respondJson(accessTokenResponder.createResponse(accessToken))
4753
}
4854

@@ -56,6 +62,8 @@ fun GrantingCall.grantAuthorizationCode() = granter("authorization_code") {
5662
)
5763
)
5864

65+
callContext.respondHeader("Cache-Control", "no-store")
66+
callContext.respondHeader("Pragma", "no-cache")
5967
callContext.respondJson(accessTokenResponder.createResponse(accessToken))
6068
}
6169

@@ -106,4 +114,4 @@ fun GrantingCall.throwExceptionIfUnverifiedClient(clientRequest: ClientRequest)
106114

107115
fun GrantingCall.scopesAllowed(clientScopes: Set<String>, requestedScopes: Set<String>): Boolean {
108116
return clientScopes.containsAll(requestedScopes)
109-
}
117+
}

0 commit comments

Comments
 (0)