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
dce31d82
Unverified
Commit
dce31d82
authored
1 year ago
by
Josiah Evans
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
feat: Add configurable CORS Headers (#3114)
Signed-off-by:
Josiah Evans
<
josiah.evans@lunit.io
>
parent
68d2a88f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/dex/config.go
+1
-0
1 addition, 0 deletions
cmd/dex/config.go
cmd/dex/serve.go
+1
-0
1 addition, 0 deletions
cmd/dex/serve.go
server/server.go
+7
-4
7 additions, 4 deletions
server/server.go
with
9 additions
and
4 deletions
cmd/dex/config.go
+
1
−
0
View file @
dce31d82
...
@@ -150,6 +150,7 @@ type Web struct {
...
@@ -150,6 +150,7 @@ type Web struct {
TLSCert
string
`json:"tlsCert"`
TLSCert
string
`json:"tlsCert"`
TLSKey
string
`json:"tlsKey"`
TLSKey
string
`json:"tlsKey"`
AllowedOrigins
[]
string
`json:"allowedOrigins"`
AllowedOrigins
[]
string
`json:"allowedOrigins"`
AllowedHeaders
[]
string
`json:"allowedHeaders"`
}
}
// Telemetry is the config format for telemetry including the HTTP server config.
// Telemetry is the config format for telemetry including the HTTP server config.
...
...
This diff is collapsed.
Click to expand it.
cmd/dex/serve.go
+
1
−
0
View file @
dce31d82
...
@@ -265,6 +265,7 @@ func runServe(options serveOptions) error {
...
@@ -265,6 +265,7 @@ func runServe(options serveOptions) error {
AlwaysShowLoginScreen
:
c
.
OAuth2
.
AlwaysShowLoginScreen
,
AlwaysShowLoginScreen
:
c
.
OAuth2
.
AlwaysShowLoginScreen
,
PasswordConnector
:
c
.
OAuth2
.
PasswordConnector
,
PasswordConnector
:
c
.
OAuth2
.
PasswordConnector
,
AllowedOrigins
:
c
.
Web
.
AllowedOrigins
,
AllowedOrigins
:
c
.
Web
.
AllowedOrigins
,
AllowedHeaders
:
c
.
Web
.
AllowedHeaders
,
Issuer
:
c
.
Issuer
,
Issuer
:
c
.
Issuer
,
Storage
:
s
,
Storage
:
s
,
Web
:
c
.
Frontend
,
Web
:
c
.
Frontend
,
...
...
This diff is collapsed.
Click to expand it.
server/server.go
+
7
−
4
View file @
dce31d82
...
@@ -77,6 +77,9 @@ type Config struct {
...
@@ -77,6 +77,9 @@ type Config struct {
// domain.
// domain.
AllowedOrigins
[]
string
AllowedOrigins
[]
string
// List of allowed headers for CORS requests on discovery, token, and keys endpoint.
AllowedHeaders
[]
string
// If enabled, the server won't prompt the user to approve authorization requests.
// If enabled, the server won't prompt the user to approve authorization requests.
// Logging in implies approval.
// Logging in implies approval.
SkipApprovalScreen
bool
SkipApprovalScreen
bool
...
@@ -214,6 +217,9 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
...
@@ -214,6 +217,9 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
if
len
(
c
.
SupportedResponseTypes
)
==
0
{
if
len
(
c
.
SupportedResponseTypes
)
==
0
{
c
.
SupportedResponseTypes
=
[]
string
{
responseTypeCode
}
c
.
SupportedResponseTypes
=
[]
string
{
responseTypeCode
}
}
}
if
len
(
c
.
AllowedHeaders
)
==
0
{
c
.
AllowedHeaders
=
[]
string
{
"Authorization"
}
}
allSupportedGrants
:=
map
[
string
]
bool
{
allSupportedGrants
:=
map
[
string
]
bool
{
grantTypeAuthorizationCode
:
true
,
grantTypeAuthorizationCode
:
true
,
...
@@ -353,12 +359,9 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
...
@@ -353,12 +359,9 @@ func newServer(ctx context.Context, c Config, rotationStrategy rotationStrategy)
handleWithCORS
:=
func
(
p
string
,
h
http
.
HandlerFunc
)
{
handleWithCORS
:=
func
(
p
string
,
h
http
.
HandlerFunc
)
{
var
handler
http
.
Handler
=
h
var
handler
http
.
Handler
=
h
if
len
(
c
.
AllowedOrigins
)
>
0
{
if
len
(
c
.
AllowedOrigins
)
>
0
{
allowedHeaders
:=
[]
string
{
"Authorization"
,
}
cors
:=
handlers
.
CORS
(
cors
:=
handlers
.
CORS
(
handlers
.
AllowedOrigins
(
c
.
AllowedOrigins
),
handlers
.
AllowedOrigins
(
c
.
AllowedOrigins
),
handlers
.
AllowedHeaders
(
a
llowedHeaders
),
handlers
.
AllowedHeaders
(
c
.
A
llowedHeaders
),
)
)
handler
=
cors
(
handler
)
handler
=
cors
(
handler
)
}
}
...
...
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