diff --git a/cmd/rdpgw/protocol/gateway.go b/cmd/rdpgw/protocol/gateway.go index 5ce6ec7..4e17dc5 100644 --- a/cmd/rdpgw/protocol/gateway.go +++ b/cmd/rdpgw/protocol/gateway.go @@ -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" { diff --git a/cmd/rdpgw/web/rdp.go b/cmd/rdpgw/web/rdp.go index bd4be8e..7b553c7 100644 --- a/cmd/rdpgw/web/rdp.go +++ b/cmd/rdpgw/web/rdp.go @@ -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"`