Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Rdpgw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirror
Rdpgw
Commits
c6cfdc4d
Commit
c6cfdc4d
authored
4 years ago
by
Bolke de Bruin
Browse files
Options
Downloads
Patches
Plain Diff
Add support for splitting the username from the domain to enable smaller tokens
parent
2628ba11
No related branches found
Branches containing commit
Tags
v2.0.2
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+3
-0
3 additions, 0 deletions
README.md
api/web.go
+17
-12
17 additions, 12 deletions
api/web.go
config/configuration.go
+1
-0
1 addition, 0 deletions
config/configuration.go
main.go
+1
-0
1 addition, 0 deletions
main.go
with
22 additions
and
12 deletions
README.md
+
3
−
0
View file @
c6cfdc4d
...
...
@@ -85,6 +85,9 @@ client:
networkAutoDetect
:
0
bandwidthAutoDetect
:
1
ConnectionType
:
6
# 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
security
:
# a random string of at least 32 characters to secure cookies on the client
# make sure to share this amongst different pods
...
...
This diff is collapsed.
Click to expand it.
api/web.go
+
17
−
12
View file @
c6cfdc4d
...
...
@@ -42,6 +42,7 @@ type Config struct {
NetworkAutoDetect
int
BandwidthAutoDetect
int
ConnectionType
int
SplitUserDomain
bool
}
func
(
c
*
Config
)
NewApi
()
{
...
...
@@ -157,17 +158,23 @@ func (c *Config) HandleDownload(w http.ResponseWriter, r *http.Request) {
host
=
strings
.
Replace
(
host
,
"{{ preferred_username }}"
,
userName
,
1
)
// split the username into user and domain
creds
:=
strings
.
SplitN
(
userName
,
"@"
,
2
)
user
:=
creds
[
0
]
var
user
string
var
domain
string
if
len
(
creds
)
>
1
{
domain
=
creds
[
1
]
if
c
.
SplitUserDomain
{
creds
:=
strings
.
SplitN
(
userName
,
"@"
,
2
)
user
=
creds
[
0
]
if
len
(
creds
)
>
1
{
domain
=
creds
[
1
]
}
}
else
{
user
=
userName
}
render
:=
user
if
c
.
UsernameTemplate
!=
""
{
c
.
UsernameTemplate
=
fmt
.
Sprintf
(
c
.
UsernameTemplate
)
us
er
=
strings
.
Replace
(
c
.
UsernameTemplate
,
"{{ username }}"
,
user
,
1
)
if
c
.
UsernameTemplate
==
us
er
{
render
=
fmt
.
Sprintf
(
c
.
UsernameTemplate
)
rend
er
=
strings
.
Replace
(
render
,
"{{ username }}"
,
user
,
1
)
if
c
.
UsernameTemplate
==
rend
er
{
log
.
Printf
(
"Invalid username template. %s == %s"
,
c
.
UsernameTemplate
,
user
)
http
.
Error
(
w
,
errors
.
New
(
"invalid server configuration"
)
.
Error
(),
http
.
StatusInternalServerError
)
return
...
...
@@ -180,17 +187,15 @@ func (c *Config) HandleDownload(w http.ResponseWriter, r *http.Request) {
http
.
Error
(
w
,
errors
.
New
(
"unable to generate gateway credentials"
)
.
Error
(),
http
.
StatusInternalServerError
)
}
userToken
:=
user
if
c
.
EnableUserToken
{
userToken
,
err
=
c
.
UserTokenGenerator
(
ctx
,
user
)
userToken
,
err
:
=
c
.
UserTokenGenerator
(
ctx
,
user
)
if
err
!=
nil
{
log
.
Printf
(
"Cannot generate token for user %s due to %s"
,
user
,
err
)
http
.
Error
(
w
,
errors
.
New
(
"unable to generate gateway credentials"
)
.
Error
(),
http
.
StatusInternalServerError
)
}
render
=
strings
.
Replace
(
render
,
"{{ token }}"
,
userToken
,
1
)
}
user
=
strings
.
Replace
(
user
,
"{{ token }}"
,
userToken
,
1
)
// authenticated
seed
:=
make
([]
byte
,
16
)
rand
.
Read
(
seed
)
...
...
@@ -207,7 +212,7 @@ func (c *Config) HandleDownload(w http.ResponseWriter, r *http.Request) {
"networkautodetect:i:"
+
strconv
.
Itoa
(
c
.
NetworkAutoDetect
)
+
"
\r\n
"
+
"bandwidthautodetect:i:"
+
strconv
.
Itoa
(
c
.
BandwidthAutoDetect
)
+
"
\r\n
"
+
"connection type:i:"
+
strconv
.
Itoa
(
c
.
ConnectionType
)
+
"
\r\n
"
+
"username:s:"
+
us
er
+
"
\r\n
"
+
"username:s:"
+
rend
er
+
"
\r\n
"
+
"domain:s:"
+
domain
+
"
\r\n
"
+
"bitmapcachesize:i:32000
\r\n
"
...
...
This diff is collapsed.
Click to expand it.
config/configuration.go
+
1
−
0
View file @
c6cfdc4d
...
...
@@ -57,6 +57,7 @@ type ClientConfig struct {
BandwidthAutoDetect
int
ConnectionType
int
UsernameTemplate
string
SplitUserDomain
bool
}
func
init
()
{
...
...
This diff is collapsed.
Click to expand it.
main.go
+
1
−
0
View file @
c6cfdc4d
...
...
@@ -76,6 +76,7 @@ func main() {
UsernameTemplate
:
conf
.
Client
.
UsernameTemplate
,
BandwidthAutoDetect
:
conf
.
Client
.
BandwidthAutoDetect
,
ConnectionType
:
conf
.
Client
.
ConnectionType
,
SplitUserDomain
:
conf
.
Client
.
SplitUserDomain
,
}
api
.
NewApi
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment