Files
zitadel/backend/v3/domain/errors.go
T
Marco A.andGitHub 3c3201e5a0 feat(session): Password Check API with relation tables (#11804)
# Which Problems Are Solved

As part of #11035 , this PR implements the password check logic for
session validation

# How the Problems Are Solved

- Add system config to default configuration of `domain` package for
easy initialization. Intialize the system settings when Zitadel starts
up
- Add password hasher verify logic to the default configuration of
`domain` package. Initialize it when Zitadel starts up.
  - Add settings repositories with their mocks
  - Implement the logic for doing a password check

# Additional Context

This is a cherry-picked PR + minor changes, coming from
https://github.com/zitadel/zitadel/pull/11164
- Relates to #11035
- Depends on https://github.com/zitadel/zitadel/pull/11777
2026-03-13 11:40:48 +01:00

118 lines
2.7 KiB
Go

package domain
import (
"fmt"
)
type wrongIDPTypeError struct {
expected IDPType
got string
}
func NewIDPWrongTypeError(expected IDPType, got fmt.Stringer) error {
return &wrongIDPTypeError{
expected: expected,
got: got.String(),
}
}
func (e *wrongIDPTypeError) Error() string {
return fmt.Sprintf("wrong idp type returned, expected: %v, got: %v", e.expected, e.got)
}
func (e *wrongIDPTypeError) Is(target error) bool {
_, ok := target.(*wrongIDPTypeError)
return ok
}
type MultipleObjectsUpdatedError struct {
Msg string
Expected int64
Actual int64
}
func NewMultipleObjectsUpdatedError(expected, actual int64) error {
return &MultipleObjectsUpdatedError{
Expected: expected,
Actual: actual,
}
}
func (err *MultipleObjectsUpdatedError) Error() string {
return fmt.Sprintf("Message=expecting %d row(s) updated, got %d", err.Expected, err.Actual)
}
func (err *MultipleObjectsUpdatedError) Is(target error) bool {
_, ok := target.(*MultipleObjectsUpdatedError)
return ok
}
type UnexpectedQueryTypeError[T any] struct {
assertedType T
}
func NewUnexpectedQueryTypeError[T any](assertedType T) error {
return &UnexpectedQueryTypeError[T]{
assertedType: assertedType,
}
}
func (u *UnexpectedQueryTypeError[T]) Error() string {
return fmt.Sprintf("Message=unexpected query type '%T'", u.assertedType)
}
type UnexpectedTextQueryOperationError[T any] struct {
assertedType T
}
func NewUnexpectedTextQueryOperationError[T any](assertedType T) error {
return &UnexpectedTextQueryOperationError[T]{
assertedType: assertedType,
}
}
func (u *UnexpectedTextQueryOperationError[T]) Error() string {
return fmt.Sprintf("Message=unexpected text query operation type '%T'", u.assertedType)
}
type PasswordVerificationError struct {
failedAttempts uint8
}
func NewPasswordVerificationError(failedPassAttempts uint8) error {
return &PasswordVerificationError{
failedAttempts: failedPassAttempts,
}
}
func (e *PasswordVerificationError) Error() string {
return fmt.Sprintf("Message=failed password attempts (%d)", e.failedAttempts)
}
func (err *PasswordVerificationError) Is(target error) bool {
_, ok := target.(*PasswordVerificationError)
return ok
}
type RowsReturnedMismatchError struct {
Msg string
Expected int64
Actual int64
}
func NewRowsReturnedMismatchError(expected, actual int64) error {
return &RowsReturnedMismatchError{
Expected: expected,
Actual: actual,
}
}
func (err *RowsReturnedMismatchError) Error() string {
return fmt.Sprintf("Message=expecting %d row(s) returned, got %d", err.Expected, err.Actual)
}
func (err *RowsReturnedMismatchError) Is(target error) bool {
_, ok := target.(*RowsReturnedMismatchError)
return ok
}