mirror of
https://github.com/bolkedebruin/rdpgw.git
synced 2026-03-30 07:26:35 +00:00
Fix username selection
This commit is contained in:
@@ -23,18 +23,18 @@ func CheckHost(ctx context.Context, host string) (bool, error) {
|
|||||||
case "roundrobin", "unsigned":
|
case "roundrobin", "unsigned":
|
||||||
var username string
|
var username string
|
||||||
|
|
||||||
log.Printf("Checking host")
|
|
||||||
s := getSessionInfo(ctx)
|
s := getSessionInfo(ctx)
|
||||||
if s == nil {
|
if s == nil || s.UserName == "" {
|
||||||
var ok bool
|
var ok bool
|
||||||
username, ok = ctx.Value("preferred_username").(string)
|
username, ok = ctx.Value("preferred_username").(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, errors.New("no valid session info or username found in context")
|
return false, errors.New("no valid session info or username found in context")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
log.Printf("Checking host for user %s", username)
|
||||||
for _, h := range Hosts {
|
for _, h := range Hosts {
|
||||||
if username != "" {
|
if username != "" {
|
||||||
h = strings.Replace(h, "{{ preferred_username }}", s.UserName, 1)
|
h = strings.Replace(h, "{{ preferred_username }}", username, 1)
|
||||||
}
|
}
|
||||||
if h == host {
|
if h == host {
|
||||||
return true, nil
|
return true, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user