mirror of
https://github.com/fosrl/badger.git
synced 2026-02-23 13:26:48 +00:00
feat: add auth headers to request
These changes are needed for the related changes in pangolin to work. See https://github.com/fosrl/pangolin/pull/807#event-17985130896
This commit is contained in:
16
main.go
16
main.go
@@ -40,6 +40,9 @@ type VerifyResponse struct {
|
|||||||
Data struct {
|
Data struct {
|
||||||
Valid bool `json:"valid"`
|
Valid bool `json:"valid"`
|
||||||
RedirectURL *string `json:"redirectUrl"`
|
RedirectURL *string `json:"redirectUrl"`
|
||||||
|
Username *string `json:"username,omitempty"`
|
||||||
|
Email *string `json:"email,omitempty"`
|
||||||
|
Name *string `json:"name,omitempty"`
|
||||||
ResponseHeaders map[string]string `json:"responseHeaders,omitempty"`
|
ResponseHeaders map[string]string `json:"responseHeaders,omitempty"`
|
||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
@@ -204,6 +207,19 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if result.Data.Valid {
|
if result.Data.Valid {
|
||||||
|
|
||||||
|
if result.Data.Username != nil {
|
||||||
|
req.Header.Add("Remote-User", *result.Data.Username)
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.Data.Email != nil {
|
||||||
|
req.Header.Add("Remote-Email", *result.Data.Email)
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.Data.Name != nil {
|
||||||
|
req.Header.Add("Remote-Name", *result.Data.Name)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("Badger: Valid session")
|
fmt.Println("Badger: Valid session")
|
||||||
p.next.ServeHTTP(rw, req)
|
p.next.ServeHTTP(rw, req)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user