Skip to content

Commit

Permalink
feat: send OIDC claim keys to tracing (#3798)
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl authored Mar 6, 2024
1 parent f8fbb00 commit 04390be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/client-go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
12 changes: 9 additions & 3 deletions selfservice/strategy/oidc/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"path/filepath"
"strings"

"golang.org/x/exp/maps"

"github.com/ory/x/urlx"

"go.opentelemetry.io/otel/attribute"
Expand Down Expand Up @@ -384,10 +386,12 @@ func (s *Strategy) HandleCallback(w http.ResponseWriter, r *http.Request, ps htt
var (
code = stringsx.Coalesce(r.URL.Query().Get("code"), r.URL.Query().Get("authCode"))
pid = ps.ByName("provider")
err error
)

ctx := r.Context()
ctx = context.WithValue(ctx, httprouter.ParamsKey, ps)
ctx := context.WithValue(r.Context(), httprouter.ParamsKey, ps)
ctx, span := s.d.Tracer(ctx).Tracer().Start(ctx, "strategy.oidc.ExchangeCode")
defer otelx.End(span, &err)
r = r.WithContext(ctx)

req, cntnr, err := s.ValidateCallback(w, r)
Expand Down Expand Up @@ -447,11 +451,13 @@ func (s *Strategy) HandleCallback(w http.ResponseWriter, r *http.Request, ps htt
}
}

if err := claims.Validate(); err != nil {
if err = claims.Validate(); err != nil {
s.forwardError(w, r, req, s.handleError(w, r, req, pid, nil, err))
return
}

span.SetAttributes(attribute.StringSlice("claims", maps.Keys(claims.RawClaims)))

switch a := req.(type) {
case *login.Flow:
if ff, err := s.processLogin(w, r, a, et, claims, provider, cntnr); err != nil {
Expand Down

0 comments on commit 04390be

Please sign in to comment.