Can omit username from rendered RDP (#83)

This commit is contained in:
Jonathan Giroux (Koltes) 2024-03-15 12:30:22 +01:00 committed by GitHub
parent 6325c0c4b7
commit 8e117ad083
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 3 deletions

View File

@ -137,6 +137,8 @@ Client:
# If true puts splits "user@domain.com" into the user and domain component so that
# domain gets set in the rdp file and the domain name is stripped from the username
SplitUserDomain: false
# If true, removes "username" (and "domain" if SplitUserDomain is true) from RDP file.
# NoUsername: true
Security:
# a random string of 32 characters to secure cookies on the client
# make sure to share this amongst different pods

View File

@ -94,6 +94,7 @@ type ClientConfig struct {
// kept for backwards compatibility
UsernameTemplate string `koanf:"usernametemplate"`
SplitUserDomain bool `koanf:"splituserdomain"`
NoUsername string `koanf:"nousername"`
}
func ToCamel(s string) string {

View File

@ -110,6 +110,7 @@ func main() {
RdpOpts: web.RdpOpts{
UsernameTemplate: conf.Client.UsernameTemplate,
SplitUserDomain: conf.Client.SplitUserDomain,
NoUsername: conf.Client.NoUsername,
},
GatewayAddress: url,
TemplateFile: conf.Client.Defaults,

View File

@ -37,6 +37,7 @@ type Config struct {
type RdpOpts struct {
UsernameTemplate string
SplitUserDomain bool
NoUsername bool
}
type Handler struct {
@ -210,9 +211,11 @@ func (h *Handler) HandleDownload(w http.ResponseWriter, r *http.Request) {
}
}
d.Settings.Username = render
if domain != "" {
d.Settings.Domain = domain
if !NoUsername {
d.Settings.Username = render
if domain != "" {
d.Settings.Domain = domain
}
}
d.Settings.FullAddress = host
d.Settings.GatewayHostname = h.gatewayAddress.Host