feat(session): IDP Intent Check API with relation tables (#11820)

# Which Problems Are Solved

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

# How the Problems Are Solved

- Inject encryption algorithm for IDP intent tokens at DB initialization
  - Add the IDP intent repository as an invoke option
  - Rework crypto mocks using gomock
  - Implement IDP intent check logic
- minor - DB: expand IDP Intent deletion testing table with a test case
where IDP intent is not found

# Noteworthy

I did not implement `domain.Transactional` given the doubts that
@adlerhurst expressed in https://github.com/zitadel/zitadel/pull/11804 .
So, there is no transaction AT ALL in here because the `Execute()`
method contains one single DB call (Delete) and `Validate()` just does
Get calls.

# 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/11804
This commit is contained in:
Marco A.
2026-03-17 10:50:47 +00:00
committed by GitHub
parent 3fdac54878
commit aa4432dc99
16 changed files with 1422 additions and 157 deletions
+23
View File
@@ -1,7 +1,11 @@
package domain
import (
"errors"
"fmt"
"github.com/zitadel/zitadel/backend/v3/storage/database"
"github.com/zitadel/zitadel/internal/zerrors"
)
type wrongIDPTypeError struct {
@@ -89,6 +93,25 @@ func (e *PasswordVerificationError) Error() string {
return fmt.Sprintf("Message=failed password attempts (%d)", e.failedAttempts)
}
// handleGetError wraps DB errors coming from Get calls into [zerrors] errors.
//
// - errorID should be in the format <package short name>-<random id>
// - objectType should be the string representation of a DB object (e.g. 'user', 'session', 'idp'...)
//
// The function wraps [database.NoRowFoundError] to [zerrors.NotFound] error
// and any other error to [zerrors.InternalError]
func handleGetError(inputErr error, errorID, objectType string) error {
if inputErr == nil {
return nil
}
if errors.Is(inputErr, &database.NoRowFoundError{}) {
return zerrors.CreateZitadelError(zerrors.KindNotFound, inputErr, errorID, fmt.Sprintf("%s not found", objectType), 1)
}
return zerrors.CreateZitadelError(zerrors.KindInternal, inputErr, errorID, fmt.Sprintf("failed fetching %s", objectType), 1)
}
func (err *PasswordVerificationError) Is(target error) bool {
_, ok := target.(*PasswordVerificationError)
return ok