Merge pull request #21 from fosrl/dev

Update information passed downstream
This commit is contained in:
Owen Schwartz
2026-06-03 14:04:35 -07:00
committed by GitHub
3 changed files with 13 additions and 3 deletions

1
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1 @@
* @oschwartz10612 @miloschwartz

BIN
go.mod

Binary file not shown.

15
main.go
View File

@@ -67,6 +67,8 @@ type VerifyResponse struct {
HeaderAuthChallenged bool `json:"headerAuthChallenged"`
Valid bool `json:"valid"`
RedirectURL *string `json:"redirectUrl"`
UserId *string `json:"userId,omitempty"`
DontStripSession bool `json:"dontStripSession,omitempty"`
Username *string `json:"username,omitempty"`
Email *string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
@@ -276,6 +278,7 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
req.Header.Del("Remote-Email")
req.Header.Del("Remote-Name")
req.Header.Del("Remote-Role")
req.Header.Del("Remote-User-Id")
if result.Data.ResponseHeaders != nil {
for key, value := range result.Data.ResponseHeaders {
@@ -305,6 +308,10 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
if result.Data.Valid {
if result.Data.UserId != nil {
req.Header.Add("Remote-User-Id", *result.Data.UserId)
}
if result.Data.Username != nil {
req.Header.Add("Remote-User", *result.Data.Username)
}
@@ -321,9 +328,11 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
req.Header.Add("Remote-Role", *result.Data.Role)
}
p.stripSessionCookies(req)
p.stripSessionParam(req)
p.stripAccessTokenHeaders(req)
if !result.Data.DontStripSession {
p.stripSessionParam(req)
p.stripSessionCookies(req)
p.stripAccessTokenHeaders(req)
}
fmt.Println("Badger: Valid session")
p.next.ServeHTTP(rw, req)