fix(oidc): multiple state cookies being sent to frontend causing invalid oauth state

This commit is contained in:
yusing
2025-05-12 14:19:18 +08:00
parent 453262832a
commit a1f2a84a16

View File

@@ -1,7 +1,6 @@
package auth
import (
"context"
"net/http"
"github.com/yusing/go-proxy/internal/common"
@@ -49,12 +48,7 @@ func RequireAuth(next http.HandlerFunc) http.HandlerFunc {
}
return func(w http.ResponseWriter, r *http.Request) {
if err := defaultAuth.CheckToken(r); err != nil {
if IsFrontend(r) {
r = r.WithContext(context.WithValue(r.Context(), nextHandlerContextKey, next))
defaultAuth.LoginHandler(w, r)
} else {
gphttp.Unauthorized(w, err.Error())
}
gphttp.Unauthorized(w, err.Error())
return
}
next(w, r)