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
5f9abc5b
Unverified
Commit
5f9abc5b
authored
3 years ago
by
Maksim Nabokikh
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2371 from seuf/authproxy-groups-configuration
Allow configuration of returned groups via authproxy connector
parents
a190bba9
4ee9658d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
connector/authproxy/authproxy.go
+23
-8
23 additions, 8 deletions
connector/authproxy/authproxy.go
with
24 additions
and
9 deletions
README.md
+
1
−
1
View file @
5f9abc5b
...
...
@@ -75,7 +75,7 @@ Dex implements the following connectors:
|
[
Google
](
https://dexidp.io/docs/connectors/google/
)
| yes | yes | yes | alpha | |
|
[
LinkedIn
](
https://dexidp.io/docs/connectors/linkedin/
)
| yes | no | no | beta | |
|
[
Microsoft
](
https://dexidp.io/docs/connectors/microsoft/
)
| yes | yes | no | beta | |
|
[
AuthProxy
](
https://dexidp.io/docs/connectors/authproxy/
)
| no |
no
| no | alpha | Authentication proxies such as Apache2 mod_auth, etc. |
|
[
AuthProxy
](
https://dexidp.io/docs/connectors/authproxy/
)
| no |
yes
| no | alpha | Authentication proxies such as Apache2 mod_auth, etc. |
|
[
Bitbucket Cloud
](
https://dexidp.io/docs/connectors/bitbucketcloud/
)
| yes | yes | no | alpha | |
|
[
OpenShift
](
https://dexidp.io/docs/connectors/openshift/
)
| no | yes | no | alpha | |
|
[
Atlassian Crowd
](
https://dexidp.io/docs/connectors/atlassiancrowd/
)
| yes | yes | yes
*
| beta | preferred_username claim must be configured through config |
...
...
This diff is collapsed.
Click to expand it.
connector/authproxy/authproxy.go
+
23
−
8
View file @
5f9abc5b
...
...
@@ -13,9 +13,14 @@ import (
)
// 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,
// X-Remote-Group and configured staticGroups as user's group.
// Headers retrieved to fetch user's email and group can be configured
// with userHeader and groupHeader.
type
Config
struct
{
UserHeader
string
`json:"userHeader"`
UserHeader
string
`json:"userHeader"`
GroupHeader
string
`json:"groupHeader"`
Groups
[]
string
`json:"staticGroups"`
}
// Open returns an authentication strategy which requires no user interaction.
...
...
@@ -24,16 +29,22 @@ func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error)
if
userHeader
==
""
{
userHeader
=
"X-Remote-User"
}
groupHeader
:=
c
.
GroupHeader
if
groupHeader
==
""
{
groupHeader
=
"X-Remote-Group"
}
return
&
callback
{
userHeader
:
userHeader
,
logger
:
logger
,
pathSuffix
:
"/"
+
id
},
nil
return
&
callback
{
userHeader
:
userHeader
,
groupHeader
:
groupHeader
,
logger
:
logger
,
pathSuffix
:
"/"
+
id
,
groups
:
c
.
Groups
},
nil
}
// Callback is a connector which returns an identity with the HTTP header
// X-Remote-User as verified email.
type
callback
struct
{
userHeader
string
logger
log
.
Logger
pathSuffix
string
userHeader
string
groupHeader
string
groups
[]
string
logger
log
.
Logger
pathSuffix
string
}
// LoginURL returns the URL to redirect the user to login with.
...
...
@@ -55,11 +66,15 @@ func (m *callback) HandleCallback(s connector.Scopes, r *http.Request) (connecto
if
remoteUser
==
""
{
return
connector
.
Identity
{},
fmt
.
Errorf
(
"required HTTP header %s is not set"
,
m
.
userHeader
)
}
// TODO: add support for X-Remote-Group, see
// https://kubernetes.io/docs/admin/authentication/#authenticating-proxy
groups
:=
m
.
groups
headerGroup
:=
r
.
Header
.
Get
(
m
.
groupHeader
)
if
headerGroup
!=
""
{
groups
=
append
(
groups
,
headerGroup
)
}
return
connector
.
Identity
{
UserID
:
remoteUser
,
// TODO: figure out if this is a bad ID value.
Email
:
remoteUser
,
EmailVerified
:
true
,
Groups
:
groups
,
},
nil
}
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