Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring headers to forward from the original request #86

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/authorization/rbac/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
// This creates a higher guarantee that your informer’s store has a perfect picture of the resources it is watching.
// There are situations where events can be missed entirely and resyncing every so often solves this.
// Setting to 0 disables the resync and makes the informer subscribe to individual updates only.
defaultResyncDuration = time.Minute * 10
defaultResyncDuration = time.Minute * 10
)

// Logger is an interface for basic log output
Expand Down
1 change: 1 addition & 0 deletions internal/configuration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Config struct {
GroupClaimPrefix string `long:"group-claim-prefix" env:"GROUP_CLAIM_PREFIX" default:"oidc:" description:"prefix oidc group claims with this value"`
EncryptionKeyString string `long:"encryption-key" env:"ENCRYPTION_KEY" description:"Encryption key used to encrypt the cookie (required)" json:"-"`
GroupsAttributeName string `long:"groups-attribute-name" env:"GROUPS_ATTRIBUTE_NAME" default:"groups" description:"Map the correct attribute that contain the user groups"`
ForwardHeaders string `long:"forward-headers" env:"FORWARD_HEADERS" default:"" description:"Headers to forward to the upstream, separated by a comma. For example: X-CSRF-Token,X-Requested-With"`

// RBAC
EnableRBAC bool `long:"enable-rbac" env:"ENABLE_RBAC" description:"Indicates that RBAC support should be enabled"`
Expand Down
9 changes: 9 additions & 0 deletions internal/handlers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,15 @@ func (s *Server) AuthHandler(rule string) http.HandlerFunc {
w.Header().Add(s.config.ForwardTokenHeaderName, s.config.ForwardTokenPrefix+id.Token)
}

// Get all headers that we want to forward from the original request
// by reading the config
headers := strings.Split(s.config.ForwardHeaders, ",")

// Forward headers
for _, header := range headers {
w.Header().Add(header, r.Header.Get(header))
}

w.WriteHeader(200)
}
}
Expand Down