mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-18 11:15:12 +00:00
feat(repository): implement user repository (#10967)
## Summary This PR introduces the relational user repository for backend v3, including schema, repository APIs, reducers/projections, and tests for both human and machine users. ## What changed * Added user-focused relational migrations (users, verifications, metadata, PATs, machine keys, passkeys, identity provider links) and related FK wiring. * Implemented/expanded repository domain contracts and storage implementations for human and machine user flows. * Added support for machine secret handling and aligned access token type modeling. * Extended user domain models (verifications, password/email/phone/TOTP state, passkeys, metadata, invite handling, identity provider links). * Updated projection/reduction coverage and integration tests for key user lifecycle events. * Regenerated and updated mocks/enums plus supporting database change/column utilities. ## Notes for reviewers * This PR is large because it establishes the foundational relational user storage layer and related test scaffolding. Sorry for that. ## Closes Closes #10218 Closes #10224 Closes #10225 Closes #10209 Closes #10802 --------- Co-authored-by: Iraq Jaber <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Marco A. <[email protected]> Co-authored-by: Tim Möhlmann <[email protected]>
This commit is contained in:
co-authored by
Iraq Jaber
Copilot
Marco A.
Tim Möhlmann
parent
40c7b38ca1
commit
5df8a97f9d
@@ -1,13 +1,18 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
)
|
||||
|
||||
type Verification struct {
|
||||
Value *string `db:"value"`
|
||||
Code []byte `db:"code"`
|
||||
ExpiresAt *time.Time `db:"expires_at"`
|
||||
FailedAttempts uint8 `db:"failed_attempts"`
|
||||
VerifiedAt time.Time `db:"verified_at"`
|
||||
ID string `json:"id" db:"id"`
|
||||
Code *crypto.CryptoValue `json:"code" db:"code"`
|
||||
CreatedAt time.Time `json:"createdAt" db:"created_at"`
|
||||
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
|
||||
ExpiresAt *time.Time `json:"expiresAt" db:"expires_at"`
|
||||
FailedAttempts uint8 `json:"failedAttempts" db:"failed_attempts"`
|
||||
}
|
||||
|
||||
type VerificationType interface {
|
||||
@@ -16,15 +21,16 @@ type VerificationType interface {
|
||||
|
||||
// VerificationTypeInit indicates that an object which needs verification is created.
|
||||
type VerificationTypeInit struct {
|
||||
// ID is the ID of the verification.
|
||||
// The id must be set if the the object can have multiple verifications.
|
||||
ID *string
|
||||
// CreatedAt is the time when the verification was created.
|
||||
// If zero, the current time will be used.
|
||||
CreatedAt time.Time
|
||||
// Expiry is the duration after which the verification expires.
|
||||
Expiry *time.Duration
|
||||
// Code is the code to be used for verification.
|
||||
Code []byte
|
||||
// Value is the value to be set after successful verification.
|
||||
Value *string
|
||||
Code *crypto.CryptoValue
|
||||
}
|
||||
|
||||
// isVerificationType implements [VerificationType].
|
||||
@@ -32,24 +38,31 @@ func (v *VerificationTypeInit) isVerificationType() {}
|
||||
|
||||
var _ VerificationType = (*VerificationTypeInit)(nil)
|
||||
|
||||
// VerificationTypeVerified indicates that the verification was successful.
|
||||
// VerificationTypeSucceeded indicates that the verification was successful.
|
||||
// If VerifiedAt is zero, the current time will be used.
|
||||
// If the Value of the verification is present, it is used as the new value to be set.
|
||||
type VerificationTypeVerified struct {
|
||||
type VerificationTypeSucceeded struct {
|
||||
// ID is the ID of the verification.
|
||||
// The id must be set if the the object can have multiple verifications.
|
||||
ID *string
|
||||
// If zero, the current time will be used.
|
||||
VerifiedAt time.Time
|
||||
}
|
||||
|
||||
// isVerificationType implements [VerificationType].
|
||||
func (v *VerificationTypeVerified) isVerificationType() {}
|
||||
func (v *VerificationTypeSucceeded) isVerificationType() {}
|
||||
|
||||
var _ VerificationType = (*VerificationTypeVerified)(nil)
|
||||
var _ VerificationType = (*VerificationTypeSucceeded)(nil)
|
||||
|
||||
// VerificationTypeUpdate updates an existing verification.
|
||||
// Non-nil fields get updated.
|
||||
type VerificationTypeUpdate struct {
|
||||
Code []byte
|
||||
Value *string
|
||||
// ID is the ID of the verification.
|
||||
// The id must be set if the the object can have multiple verifications.
|
||||
ID *string
|
||||
Code *crypto.CryptoValue
|
||||
Expiry *time.Duration
|
||||
// If zero, the current time will be used.
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
// isVerificationType implements [VerificationType].
|
||||
@@ -58,10 +71,12 @@ func (v *VerificationTypeUpdate) isVerificationType() {}
|
||||
var _ VerificationType = (*VerificationTypeUpdate)(nil)
|
||||
|
||||
// VerificationTypeSkipped indicates that the verification was skipped.
|
||||
// If Value is present, it is used as the new value to be set.
|
||||
type VerificationTypeSkipped struct {
|
||||
VerifiedAt time.Time
|
||||
Value *string
|
||||
// ID is the ID of the verification.
|
||||
// The id must be set if the the object can have multiple verifications.
|
||||
ID *string
|
||||
// If zero, the current time will be used.
|
||||
SkippedAt time.Time
|
||||
}
|
||||
|
||||
// isVerificationType implements [VerificationType].
|
||||
@@ -70,6 +85,10 @@ func (v *VerificationTypeSkipped) isVerificationType() {}
|
||||
var _ VerificationType = (*VerificationTypeSkipped)(nil)
|
||||
|
||||
type VerificationTypeFailed struct {
|
||||
// ID is the ID of the verification.
|
||||
// The id must be set if the the object can have multiple verifications.
|
||||
ID *string
|
||||
// If zero, the current time will be used.
|
||||
FailedAt time.Time
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user