Skip to content

Commit 69c6c0b

Browse files
committed
fix: add cache control header to token response
1 parent a71f61d commit 69c6c0b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/controller/oidc_controller.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (controller *OIDCController) Token(c *gin.Context) {
231231
if !ok {
232232
tlog.App.Error().Msg("Missing authorization header")
233233
c.Header("www-authenticate", "basic")
234-
c.JSON(401, gin.H{
234+
c.JSON(400, gin.H{
235235
"error": "invalid_client",
236236
})
237237
return
@@ -313,15 +313,15 @@ func (controller *OIDCController) Token(c *gin.Context) {
313313
if err != nil {
314314
if errors.Is(err, service.ErrTokenExpired) {
315315
tlog.App.Error().Err(err).Msg("Refresh token expired")
316-
c.JSON(401, gin.H{
316+
c.JSON(400, gin.H{
317317
"error": "invalid_grant",
318318
})
319319
return
320320
}
321321

322322
if errors.Is(err, service.ErrInvalidClient) {
323323
tlog.App.Error().Err(err).Msg("Invalid client")
324-
c.JSON(401, gin.H{
324+
c.JSON(400, gin.H{
325325
"error": "invalid_grant",
326326
})
327327
return
@@ -337,6 +337,9 @@ func (controller *OIDCController) Token(c *gin.Context) {
337337
tokenResponse = tokenRes
338338
}
339339

340+
c.Header("cache-control", "no-store")
341+
c.Header("pragma", "no-cache")
342+
340343
c.JSON(200, tokenResponse)
341344
}
342345

0 commit comments

Comments
 (0)