Compare commits

...

2 Commits

Author SHA1 Message Date
yusing
a1f2a84a16 fix(oidc): multiple state cookies being sent to frontend causing invalid oauth state 2025-05-12 14:19:18 +08:00
yusing
453262832a security: disallow tls1.0/1.1 2025-05-12 12:22:52 +08:00
2 changed files with 3 additions and 8 deletions

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)

View File

@@ -73,6 +73,7 @@ func NewServer(opt Options) (s *Server) {
Handler: opt.Handler,
TLSConfig: &tls.Config{
GetCertificate: opt.CertProvider.GetCert,
MinVersion: tls.VersionTLS12,
},
}
}
@@ -169,7 +170,7 @@ func stop[Server httpServer](srv Server, logger *zerolog.Logger) {
proto := proto(srv)
ctx, cancel := context.WithTimeout(task.RootContext(), 3*time.Second)
ctx, cancel := context.WithTimeout(task.RootContext(), 1*time.Second)
defer cancel()
if err := srv.Shutdown(ctx); err != nil {