Skip to content

Commit

Permalink
Fix oauth endpoint to support detecting https in 'Forwarded' header, …
Browse files Browse the repository at this point in the history
…enabling google support (#359)
  • Loading branch information
zdebel authored Oct 31, 2024
1 parent 4fd0832 commit d5e66d3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ func oauth(ctx echo.Context) error {
httpProtocol = "https"
}

forwarded_hdr := ctx.Request().Header.Get("Forwarded")
if forwarded_hdr != "" {
fields := strings.Split(forwarded_hdr, ";")
fwd := make(map[string]string)
for _, v := range fields {
p := strings.Split(v, "=")
fwd[p[0]] = p[1]
}
val, ok := fwd["proto"]
if ok && val == "https" {
httpProtocol = "https"
}
}

var opengistUrl string
if config.C.ExternalUrl != "" {
opengistUrl = config.C.ExternalUrl
Expand Down

0 comments on commit d5e66d3

Please sign in to comment.