Files
zitadel/backend/v3/domain/session_user_agent.go
T
Livio SpringandGitHub 4e6f68c511 feat(relational): implement session repository (#11109)
# Which Problems Are Solved

As part of going to a relation storage model, we need to implement the
repository for handling sessions and their events.

# How the Problems Are Solved

- Adds a migration step to create the necessary tables and types in the
database.
- Adds the repository implementation for sessions.
- Implements a projection handler for session events to handle the
events written by the old command handlers.
- Updates the `Session` type and `SessionRepository` interface:
  - added `CreatorID`
  - Adjusted `Delete` method to return amount of affected columns
  - Removed sub-repository clumns from the main interface
- Added `CreatorIDCondition`, `ExpirationCondition`, `ExistsFactor` and
`ExistsMetadata`
  - Removed `SetUserAgent`
- Methods of `SessionFactor` and `SessionChallenge` have been made
public
- fixed enumer on `SessionFactorType`
- Adds a `JSON` type to the repository package to easy can JSON columns,
resp. jsonb object inside a property of a `JSONArray` object.
- Adds a `NoChange` interface, which can be implemented to signal that a
`Change` interface implementation is not writing any changes to the
statement builder, e.g. `CTEChange`

# Additional Changes

- Fixes the operators enums. `TextOperations` had wrong comments and
`NumberOperations` additionally also had from comparisons.
- Fixes downgrade of migration step 008.

# Additional Context

- closes https://github.com/zitadel/zitadel/issues/10212
2026-01-06 08:08:11 +01:00

38 lines
1.4 KiB
Go

package domain
import (
"net"
"net/http"
"github.com/zitadel/zitadel/backend/v3/storage/database"
)
type SessionUserAgent struct {
FingerprintID *string `json:"fingerprintId,omitempty" db:"fingerprint_id"`
Description *string `json:"description,omitempty" db:"description"`
IP net.IP `json:"ip,omitempty" db:"ip"`
Header http.Header `json:"headers,omitempty" db:"headers"`
}
type SessionUserAgentColumns interface {
// InstanceIDColumn returns the column for the instance id field.
InstanceIDColumn() database.Column
// FingerprintIDColumn returns the column for the fingerprint id field.
FingerprintIDColumn() database.Column
// IPColumn returns the column for the ip field.
IPColumn() database.Column
// DescriptionColumn returns the column for the description field.
DescriptionColumn() database.Column
// HeadersColumn returns the column for the headers field.
HeadersColumn() database.Column
}
type SessionUserAgentConditions interface {
// PrimaryKeyCondition returns a filter on the primary key fields.
PrimaryKeyCondition(instanceID, fingerprintID string) database.Condition
// InstanceIDCondition returns an equal filter on the instance id field.
InstanceIDCondition(instanceID string) database.Condition
// FingerprintIDCondition returns an equal filter on the fingerprint id field.
FingerprintIDCondition(fingerprintID string) database.Condition
}