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
28890a97
Commit
28890a97
authored
2 years ago
by
Bolke de Bruin
Browse files
Options
Downloads
Patches
Plain Diff
Fix username replacement
parent
184ff320
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/rdpgw/api/basic.go
+0
-1
0 additions, 1 deletion
cmd/rdpgw/api/basic.go
cmd/rdpgw/security/basic.go
+8
-2
8 additions, 2 deletions
cmd/rdpgw/security/basic.go
with
8 additions
and
3 deletions
cmd/rdpgw/api/basic.go
+
0
−
1
View file @
28890a97
...
@@ -48,7 +48,6 @@ func (c *Config) BasicAuth(next http.HandlerFunc) http.HandlerFunc {
...
@@ -48,7 +48,6 @@ func (c *Config) BasicAuth(next http.HandlerFunc) http.HandlerFunc {
log
.
Printf
(
"User %s is not authenticated for this service"
,
username
)
log
.
Printf
(
"User %s is not authenticated for this service"
,
username
)
}
else
{
}
else
{
ctx
:=
context
.
WithValue
(
r
.
Context
(),
"preferred_username"
,
username
)
ctx
:=
context
.
WithValue
(
r
.
Context
(),
"preferred_username"
,
username
)
ctx
=
context
.
WithValue
(
ctx
,
"access_token"
,
"EMPTY"
)
next
.
ServeHTTP
(
w
,
r
.
WithContext
(
ctx
))
next
.
ServeHTTP
(
w
,
r
.
WithContext
(
ctx
))
return
return
}
}
...
...
This diff is collapsed.
Click to expand it.
cmd/rdpgw/security/basic.go
+
8
−
2
View file @
28890a97
...
@@ -21,13 +21,19 @@ func CheckHost(ctx context.Context, host string) (bool, error) {
...
@@ -21,13 +21,19 @@ func CheckHost(ctx context.Context, host string) (bool, error) {
// todo get from context?
// todo get from context?
return
false
,
errors
.
New
(
"cannot verify host in 'signed' mode as token data is missing"
)
return
false
,
errors
.
New
(
"cannot verify host in 'signed' mode as token data is missing"
)
case
"roundrobin"
,
"unsigned"
:
case
"roundrobin"
,
"unsigned"
:
var
username
string
log
.
Printf
(
"Checking host"
)
log
.
Printf
(
"Checking host"
)
s
:=
getSessionInfo
(
ctx
)
s
:=
getSessionInfo
(
ctx
)
if
s
==
nil
{
if
s
==
nil
{
return
false
,
errors
.
New
(
"no valid session info found in context"
)
var
ok
bool
username
,
ok
=
ctx
.
Value
(
"preferred_username"
)
.
(
string
)
if
!
ok
{
return
false
,
errors
.
New
(
"no valid session info or username found in context"
)
}
}
}
for
_
,
h
:=
range
Hosts
{
for
_
,
h
:=
range
Hosts
{
if
s
.
U
ser
N
ame
!=
""
{
if
u
ser
n
ame
!=
""
{
h
=
strings
.
Replace
(
h
,
"{{ preferred_username }}"
,
s
.
UserName
,
1
)
h
=
strings
.
Replace
(
h
,
"{{ preferred_username }}"
,
s
.
UserName
,
1
)
}
}
if
h
==
host
{
if
h
==
host
{
...
...
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