Commit eba4454a authored by qiuqunfeng's avatar qiuqunfeng
Browse files

Enhance SSO authentication middleware with robust HTTP client configuration

- Add timeout and TLS configuration to HTTP client in AuthMiddleware
- Enable insecure TLS connection for SSO service requests
- Log errors for failed SSO authentication requests
- Improve error handling and network resilience in authentication process
parent f4330099
package middleware
import (
"crypto/tls"
"encoding/json"
"io"
"net/http"
"time"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
......@@ -45,9 +47,17 @@ func AuthMiddleware(ssoUrl string) gin.HandlerFunc {
}
// Make request to SSO service
client := &http.Client{}
client := &http.Client{
Timeout: 10 * time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
resp, err := client.Do(req)
if err != nil {
log.Error().Err(err).Msg("failed to make sso request")
utils.AssembleResponse(c, nil, utils.ErrInternalServer)
c.Abort()
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment