Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
hdacloud
dex
Commits
a12a919d
Commit
a12a919d
authored
4 years ago
by
seuf
Browse files
Options
Downloads
Patches
Plain Diff
Allow configuration of returned auth proxy header
Signed-off-by:
seuf
<
seuf76@gmail.com
>
parent
2a282860
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
connector/authproxy/authproxy.go
+10
-4
10 additions, 4 deletions
connector/authproxy/authproxy.go
with
10 additions
and
4 deletions
connector/authproxy/authproxy.go
+
10
−
4
View file @
a12a919d
...
@@ -14,16 +14,22 @@ import (
...
@@ -14,16 +14,22 @@ import (
// Config holds the configuration parameters for a connector which returns an
// Config holds the configuration parameters for a connector which returns an
// identity with the HTTP header X-Remote-User as verified email.
// identity with the HTTP header X-Remote-User as verified email.
type
Config
struct
{}
type
Config
struct
{
HeaderName
string
`json:"headerName"`
}
// Open returns an authentication strategy which requires no user interaction.
// Open returns an authentication strategy which requires no user interaction.
func
(
c
*
Config
)
Open
(
id
string
,
logger
log
.
Logger
)
(
connector
.
Connector
,
error
)
{
func
(
c
*
Config
)
Open
(
id
string
,
logger
log
.
Logger
)
(
connector
.
Connector
,
error
)
{
return
&
callback
{
logger
:
logger
,
pathSuffix
:
"/"
+
id
},
nil
if
c
.
HeaderName
==
""
{
c
.
HeaderName
=
"X-Remote-User"
}
return
&
callback
{
headerName
:
c
.
HeaderName
,
logger
:
logger
,
pathSuffix
:
"/"
+
id
},
nil
}
}
// Callback is a connector which returns an identity with the HTTP header
// Callback is a connector which returns an identity with the HTTP header
// X-Remote-User as verified email.
// X-Remote-User as verified email.
type
callback
struct
{
type
callback
struct
{
headerName
string
logger
log
.
Logger
logger
log
.
Logger
pathSuffix
string
pathSuffix
string
}
}
...
@@ -43,9 +49,9 @@ func (m *callback) LoginURL(s connector.Scopes, callbackURL, state string) (stri
...
@@ -43,9 +49,9 @@ func (m *callback) LoginURL(s connector.Scopes, callbackURL, state string) (stri
// HandleCallback parses the request and returns the user's identity
// HandleCallback parses the request and returns the user's identity
func
(
m
*
callback
)
HandleCallback
(
s
connector
.
Scopes
,
r
*
http
.
Request
)
(
connector
.
Identity
,
error
)
{
func
(
m
*
callback
)
HandleCallback
(
s
connector
.
Scopes
,
r
*
http
.
Request
)
(
connector
.
Identity
,
error
)
{
remoteUser
:=
r
.
Header
.
Get
(
"X-Remote-User"
)
remoteUser
:=
r
.
Header
.
Get
(
m
.
headerName
)
if
remoteUser
==
""
{
if
remoteUser
==
""
{
return
connector
.
Identity
{},
fmt
.
Errorf
(
"required HTTP header
X-Remote-User is not set"
)
return
connector
.
Identity
{},
fmt
.
Errorf
(
"required HTTP header
%s is not set"
,
m
.
headerName
)
}
}
// TODO: add support for X-Remote-Group, see
// TODO: add support for X-Remote-Group, see
// https://kubernetes.io/docs/admin/authentication/#authenticating-proxy
// https://kubernetes.io/docs/admin/authentication/#authenticating-proxy
...
...
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