mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-22 13:17:41 +00:00
fix(oidc): log oidc errors
This commit is contained in:
@@ -3,6 +3,8 @@ package oidc
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"github.com/zitadel/logging"
|
||||||
|
|
||||||
"github.com/zitadel/oidc/v3/pkg/oidc"
|
"github.com/zitadel/oidc/v3/pkg/oidc"
|
||||||
"github.com/zitadel/oidc/v3/pkg/op"
|
"github.com/zitadel/oidc/v3/pkg/op"
|
||||||
|
|
||||||
@@ -19,6 +21,7 @@ func oidcError(err error) error {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
logging.WithError(err).Warn("OIDC error")
|
||||||
if errors.Is(err, op.ErrInvalidRefreshToken) {
|
if errors.Is(err, op.ErrInvalidRefreshToken) {
|
||||||
err = zerrors.ThrowInvalidArgument(err, "OIDCS-ef2Gi", "Errors.User.RefreshToken.Invalid")
|
err = zerrors.ThrowInvalidArgument(err, "OIDCS-ef2Gi", "Errors.User.RefreshToken.Invalid")
|
||||||
}
|
}
|
||||||
@@ -42,6 +45,14 @@ func oidcError(err error) error {
|
|||||||
if statusCode < 500 {
|
if statusCode < 500 {
|
||||||
newOidcErr = oidc.ErrInvalidRequest
|
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(
|
return op.NewStatusError(
|
||||||
newOidcErr().
|
newOidcErr().
|
||||||
WithParent(err).
|
WithParent(err).
|
||||||
|
@@ -207,7 +207,7 @@ func (s *Server) createDiscoveryConfig(ctx context.Context, supportedUILocales o
|
|||||||
|
|
||||||
func response(resp any, err error) (*op.Response, error) {
|
func response(resp any, err error) (*op.Response, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, oidcError(err)
|
||||||
}
|
}
|
||||||
return op.NewResponse(resp), nil
|
return op.NewResponse(resp), nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user