mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 07:37:31 +00:00
chore: move the go code into a subfolder
This commit is contained in:
48
apps/api/internal/domain/oidc_error_reason.go
Normal file
48
apps/api/internal/domain/oidc_error_reason.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/zitadel/oidc/v3/pkg/oidc"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type OIDCErrorReason int32
|
||||
|
||||
const (
|
||||
OIDCErrorReasonUnspecified OIDCErrorReason = iota
|
||||
OIDCErrorReasonInvalidRequest
|
||||
OIDCErrorReasonUnauthorizedClient
|
||||
OIDCErrorReasonAccessDenied
|
||||
OIDCErrorReasonUnsupportedResponseType
|
||||
OIDCErrorReasonInvalidScope
|
||||
OIDCErrorReasonServerError
|
||||
OIDCErrorReasonTemporaryUnavailable
|
||||
OIDCErrorReasonInteractionRequired
|
||||
OIDCErrorReasonLoginRequired
|
||||
OIDCErrorReasonAccountSelectionRequired
|
||||
OIDCErrorReasonConsentRequired
|
||||
OIDCErrorReasonInvalidRequestURI
|
||||
OIDCErrorReasonInvalidRequestObject
|
||||
OIDCErrorReasonRequestNotSupported
|
||||
OIDCErrorReasonRequestURINotSupported
|
||||
OIDCErrorReasonRegistrationNotSupported
|
||||
OIDCErrorReasonInvalidGrant
|
||||
)
|
||||
|
||||
func OIDCErrorReasonFromError(err error) OIDCErrorReason {
|
||||
if errors.Is(err, oidc.ErrInvalidRequest()) {
|
||||
return OIDCErrorReasonInvalidRequest
|
||||
}
|
||||
if errors.Is(err, oidc.ErrInvalidGrant()) {
|
||||
return OIDCErrorReasonInvalidGrant
|
||||
}
|
||||
if zerrors.IsPreconditionFailed(err) {
|
||||
return OIDCErrorReasonAccessDenied
|
||||
}
|
||||
if zerrors.IsInternal(err) {
|
||||
return OIDCErrorReasonServerError
|
||||
}
|
||||
return OIDCErrorReasonUnspecified
|
||||
}
|
Reference in New Issue
Block a user