mirror of
https://github.com/bolkedebruin/rdpgw.git
synced 2026-03-27 22:46:37 +00:00
Add BasicAuthTimeout setting versus static 5 seconds (#90)
This commit is contained in:
@@ -51,6 +51,7 @@ type ServerConfig struct {
|
||||
Tls string `koanf:"tls"`
|
||||
Authentication []string `koanf:"authentication"`
|
||||
AuthSocket string `koanf:"authsocket"`
|
||||
BasicAuthTimeout int `koanf:"basicauthtimeout"`
|
||||
}
|
||||
|
||||
type KerberosConfig struct {
|
||||
@@ -143,6 +144,7 @@ func Load(configFile string) Configuration {
|
||||
"Server.HostSelection": "roundrobin",
|
||||
"Server.Authentication": "openid",
|
||||
"Server.AuthSocket": "/tmp/rdpgw-auth.sock",
|
||||
"Server.BasicAuthTimeout": 5,
|
||||
"Client.NetworkAutoDetect": 1,
|
||||
"Client.BandwidthAutoDetect": 1,
|
||||
"Security.VerifyClientIp": true,
|
||||
|
||||
@@ -232,7 +232,7 @@ func main() {
|
||||
// basic auth
|
||||
if conf.Server.BasicAuthEnabled() {
|
||||
log.Printf("enabling basic authentication")
|
||||
q := web.BasicAuthHandler{SocketAddress: conf.Server.AuthSocket}
|
||||
q := web.BasicAuthHandler{SocketAddress: conf.Server.AuthSocket, Timeout: conf.Server.BasicAuthTimeout}
|
||||
rdp.NewRoute().HeadersRegexp("Authorization", "Basic").HandlerFunc(q.BasicAuth(gw.HandleGatewayProtocol))
|
||||
auth.Register(`Basic realm="restricted", charset="UTF-8"`)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ const (
|
||||
|
||||
type BasicAuthHandler struct {
|
||||
SocketAddress string
|
||||
Timeout int
|
||||
}
|
||||
|
||||
func (h *BasicAuthHandler) BasicAuth(next http.HandlerFunc) http.HandlerFunc {
|
||||
@@ -38,7 +39,7 @@ func (h *BasicAuthHandler) BasicAuth(next http.HandlerFunc) http.HandlerFunc {
|
||||
defer conn.Close()
|
||||
|
||||
c := auth.NewAuthenticateClient(conn)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(h.Timeout))
|
||||
defer cancel()
|
||||
|
||||
req := &auth.UserPass{Username: username, Password: password}
|
||||
|
||||
Reference in New Issue
Block a user