diff --git a/pkg/handler/handler.go b/pkg/handler/handler.go index 8016c89..7e690e5 100644 --- a/pkg/handler/handler.go +++ b/pkg/handler/handler.go @@ -7,7 +7,6 @@ import ( "fmt" "net/http" urllib "net/url" - "strings" "time" "github.com/sethvargo/go-retry" @@ -215,7 +214,7 @@ func (s *Standalone) LoginCallback(w http.ResponseWriter, r *http.Request) { } mw.LogEntryFrom(r).WithFields(fields).Info("callback: successful login") - metrics.ObserveLogin(tokens.IDToken.GetAmrClaim(), strings.TrimSuffix(redirect, "/")) + metrics.ObserveLogin(tokens.IDToken.GetAmrClaim(), redirect) cookie.Clear(w, cookie.Retry, s.GetCookieOptions(r)) http.Redirect(w, r, redirect, http.StatusTemporaryRedirect) } diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 1fee6f8..a605cae 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -2,6 +2,8 @@ package metrics import ( "net/http" + "net/url" + "strings" "time" "github.com/prometheus/client_golang/prometheus" @@ -153,6 +155,14 @@ func ObserveRedisLatency(operation string, fun func() error) error { } func ObserveLogin(amrValue, redirect string) { + u, err := url.Parse(redirect) + if err == nil { + u.Path = strings.TrimSuffix(u.Path, "/") + u.RawQuery = "" + u.RawFragment = "" + redirect = u.String() + } + Logins.With(prometheus.Labels{ LabelAmr: amrValue, LabelRedirect: redirect,