Fix rdp setting and fix username can be nil with openid

This commit is contained in:
Bolke de Bruin
2022-10-06 09:19:50 +02:00
parent e3ae09b525
commit 04988650e8
2 changed files with 9 additions and 3 deletions

View File

@@ -60,7 +60,7 @@ func (g *Gateway) HandleGatewayProtocol(w http.ResponseWriter, r *http.Request)
var t *Tunnel
ctx := context.WithValue(r.Context(), common.TunnelCtx, t)
ctx := r.Context()
connId := r.Header.Get(rdgConnectionIdKey)
x, found := c.Get(connId)
@@ -70,9 +70,15 @@ func (g *Gateway) HandleGatewayProtocol(w http.ResponseWriter, r *http.Request)
RemoteAddr: ctx.Value(common.ClientIPCtx).(string),
UserName: ctx.Value(common.UsernameCtx).(string),
}
// username can be nil with openid as it's only available later
username := ctx.Value(common.UsernameCtx)
if username != nil {
t.UserName = username.(string)
}
} else {
t = x.(*Tunnel)
}
ctx = context.WithValue(ctx, common.TunnelCtx, t)
if r.Method == MethodRDGOUT {
if r.Header.Get("Connection") != "upgrade" && r.Header.Get("Upgrade") != "websocket" {

View File

@@ -28,8 +28,8 @@ type RdpConnection struct {
AlternateFullAddress string `rdp:"alternate full address"`
Username string `rdp:"username"`
Domain string `rdp:"domain"`
GatewayCredentialSource int `rdp:"gatewaycredentialsource" default:"0"`
GatewayCredentialMethode int `rdp:"gatewayprofileusagemethod" default:"0"`
GatewayCredentialsSource int `rdp:"gatewaycredentialssource" default:"0"`
GatewayCredentialMethod int `rdp:"gatewayprofileusagemethod" default:"0"`
GatewayUsageMethod int `rdp:"gatewayusagemethod" default:"0"`
GatewayAccessToken string `rdp:"gatewayaccesstoken"`
PromptCredentialsOnce bool `rdp:"promptcredentialonce" default:"true"`