fix(oidc): log oidc errors

This commit is contained in:
Tim Möhlmann
2025-04-28 17:18:05 +02:00
parent 57b08dcf10
commit 0a08c854a8
2 changed files with 12 additions and 1 deletions

View File

@@ -3,6 +3,8 @@ package oidc
import (
"errors"
"github.com/zitadel/logging"
"github.com/zitadel/oidc/v3/pkg/oidc"
"github.com/zitadel/oidc/v3/pkg/op"
@@ -19,6 +21,7 @@ func oidcError(err error) error {
if err == nil {
return nil
}
logging.WithError(err).Warn("OIDC error")
if errors.Is(err, op.ErrInvalidRefreshToken) {
err = zerrors.ThrowInvalidArgument(err, "OIDCS-ef2Gi", "Errors.User.RefreshToken.Invalid")
}
@@ -42,6 +45,14 @@ func oidcError(err error) error {
if statusCode < 500 {
newOidcErr = oidc.ErrInvalidRequest
}
entry := logging.WithError(err).WithField("status_code", statusCode)
if statusCode >= 500 {
entry.Error("OIDC error")
} else {
entry.Warn("OIDC error")
}
return op.NewStatusError(
newOidcErr().
WithParent(err).

View File

@@ -207,7 +207,7 @@ func (s *Server) createDiscoveryConfig(ctx context.Context, supportedUILocales o
func response(resp any, err error) (*op.Response, error) {
if err != nil {
return nil, err
return nil, oidcError(err)
}
return op.NewResponse(resp), nil
}