Files
zitadel/backend/v3/domain/invoker_transaction.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

44 lines
1.3 KiB
Go

package domain
import (
"context"
)
// transactionInvoker ensures that [InvokeOpts].DB() returns a [database.Transaction].
// if a new transaction is started, it will be committed or rolled back after the [Executor] execution.
type transactionInvoker struct {
invoker
}
// NewTransactionInvoker creates a new [transactionInvoker].
func NewTransactionInvoker(next Invoker) *transactionInvoker {
return &transactionInvoker{
invoker: invoker{next: next},
}
}
// Transactional is implemented by [Commander]s and [Querier]s wishing to access the DB inside a transaction.
//
// It is NOT recommended to use this when non-DB operation inside a transaction take time (e.g. password hash verification).
// In that case, it is advisable to manually manage the transaction by type asserting [database.Beginner] on db.DB()
//
//go:generate mockgen -destination=mock/transactional.mock.go -package=domainmock . Transactional
type Transactional interface {
RequiresTransaction()
}
// Invoke implements [Invoker].
func (i *transactionInvoker) Invoke(ctx context.Context, executor Executor, opts *InvokeOpts) (err error) {
if _, ok := executor.(Transactional); !ok {
return i.execute(ctx, executor, opts)
}
close, err := i.ensureTx(ctx, opts)
if err != nil {
return err
}
defer func() { err = close(err) }()
return i.execute(ctx, executor, opts)
}