fix: add cache control header to token response

This commit is contained in:
Stavros
2026-03-04 19:38:52 +02:00
parent a71f61df8d
commit 69c6c0ba1d

View File

@@ -231,7 +231,7 @@ func (controller *OIDCController) Token(c *gin.Context) {
if !ok { if !ok {
tlog.App.Error().Msg("Missing authorization header") tlog.App.Error().Msg("Missing authorization header")
c.Header("www-authenticate", "basic") c.Header("www-authenticate", "basic")
c.JSON(401, gin.H{ c.JSON(400, gin.H{
"error": "invalid_client", "error": "invalid_client",
}) })
return return
@@ -313,7 +313,7 @@ func (controller *OIDCController) Token(c *gin.Context) {
if err != nil { if err != nil {
if errors.Is(err, service.ErrTokenExpired) { if errors.Is(err, service.ErrTokenExpired) {
tlog.App.Error().Err(err).Msg("Refresh token expired") tlog.App.Error().Err(err).Msg("Refresh token expired")
c.JSON(401, gin.H{ c.JSON(400, gin.H{
"error": "invalid_grant", "error": "invalid_grant",
}) })
return return
@@ -321,7 +321,7 @@ func (controller *OIDCController) Token(c *gin.Context) {
if errors.Is(err, service.ErrInvalidClient) { if errors.Is(err, service.ErrInvalidClient) {
tlog.App.Error().Err(err).Msg("Invalid client") tlog.App.Error().Err(err).Msg("Invalid client")
c.JSON(401, gin.H{ c.JSON(400, gin.H{
"error": "invalid_grant", "error": "invalid_grant",
}) })
return return
@@ -337,6 +337,9 @@ func (controller *OIDCController) Token(c *gin.Context) {
tokenResponse = tokenRes tokenResponse = tokenRes
} }
c.Header("cache-control", "no-store")
c.Header("pragma", "no-cache")
c.JSON(200, tokenResponse) c.JSON(200, tokenResponse)
} }