Skip to content

Commit 1c4e29f

Browse files
committed
fix: access_token renew + web_message redirect
1 parent 7a28795 commit 1c4e29f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

server/handlers/authorize.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func AuthorizeHandler() gin.HandlerFunc {
139139
"error_description": "code challenge is required",
140140
},
141141
}, http.StatusOK)
142+
return
142143
}
143144

144145
loginError := map[string]interface{}{
@@ -268,7 +269,7 @@ func AuthorizeHandler() gin.HandlerFunc {
268269
return
269270
}
270271

271-
if err := memorystore.Provider.SetUserSession(sessionKey, constants.TokenTypeAccessToken+"_"+nonce, authToken.FingerPrintHash); err != nil {
272+
if err := memorystore.Provider.SetUserSession(sessionKey, constants.TokenTypeAccessToken+"_"+nonce, authToken.AccessToken.Token); err != nil {
272273
log.Debug("SetUserSession failed: ", err)
273274
handleResponse(gc, responseMode, loginURL, redirectURI, loginError, http.StatusOK)
274275
return
@@ -321,6 +322,7 @@ func AuthorizeHandler() gin.HandlerFunc {
321322
}
322323

323324
handleResponse(gc, responseMode, loginURL, redirectURI, loginError, http.StatusOK)
325+
return
324326
}
325327
}
326328

@@ -349,14 +351,13 @@ func handleResponse(gc *gin.Context, responseMode, loginURI, redirectURI string,
349351
isAuthenticationRequired = true
350352
}
351353

352-
if isAuthenticationRequired {
354+
if isAuthenticationRequired && responseMode != constants.ResponseModeWebMessage {
353355
gc.Redirect(http.StatusFound, loginURI)
354356
return
355357
}
356358

357359
switch responseMode {
358360
case constants.ResponseModeQuery, constants.ResponseModeFragment:
359-
360361
gc.Redirect(http.StatusFound, redirectURI)
361362
return
362363
case constants.ResponseModeWebMessage:

server/middlewares/cors.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
func CORSMiddleware() gin.HandlerFunc {
1010
return func(c *gin.Context) {
1111
origin := c.Request.Header.Get("Origin")
12-
1312
if validators.IsValidOrigin(origin) {
1413
c.Writer.Header().Set("Access-Control-Allow-Origin", origin)
1514
}

0 commit comments

Comments
 (0)