mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:07:31 +00:00
feat: handle instanceID in projections (#3442)
* feat: handle instanceID in projections * rename functions * fix key lock * fix import
This commit is contained in:
@@ -59,6 +59,8 @@ func (key ExternalIDPSearchKey) ToColumnName() string {
|
||||
return ExternalIDPKeyIDPConfigID
|
||||
case usr_model.ExternalIDPSearchKeyResourceOwner:
|
||||
return ExternalIDPKeyResourceOwner
|
||||
case usr_model.ExternalIDPSearchKeyInstanceID:
|
||||
return ExternalIDPKeyInstanceID
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ const (
|
||||
ExternalIDPKeyUserID = "user_id"
|
||||
ExternalIDPKeyIDPConfigID = "idp_config_id"
|
||||
ExternalIDPKeyResourceOwner = "resource_owner"
|
||||
ExternalIDPKeyInstanceID = "instance_id"
|
||||
)
|
||||
|
||||
type ExternalIDPView struct {
|
||||
@@ -29,7 +30,7 @@ type ExternalIDPView struct {
|
||||
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
|
||||
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id;primary_key"`
|
||||
}
|
||||
|
||||
func (i *ExternalIDPView) AppendEvent(event *models.Event) (err error) {
|
||||
|
@@ -18,6 +18,7 @@ import (
|
||||
const (
|
||||
NotifyUserKeyUserID = "id"
|
||||
NotifyUserKeyResourceOwner = "resource_owner"
|
||||
NotifyUserKeyInstanceID = "instance_id"
|
||||
)
|
||||
|
||||
type NotifyUser struct {
|
||||
@@ -41,7 +42,7 @@ type NotifyUser struct {
|
||||
PasswordSet bool `json:"-" gorm:"column:password_set"`
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
State int32 `json:"-" gorm:"-"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id;primary_key"`
|
||||
}
|
||||
|
||||
func (u *NotifyUser) GenerateLoginName(domain string, appendDomain bool) string {
|
||||
|
@@ -55,6 +55,8 @@ func (key NotifyUserSearchKey) ToColumnName() string {
|
||||
return NotifyUserKeyUserID
|
||||
case usr_model.NotifyUserSearchKeyResourceOwner:
|
||||
return NotifyUserKeyResourceOwner
|
||||
case usr_model.NotifyUserSearchKeyInstanceID:
|
||||
return NotifyUserKeyInstanceID
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ type RefreshTokenView struct {
|
||||
IdleExpiration time.Time `json:"-" gorm:"column:idle_expiration"`
|
||||
Expiration time.Time `json:"-" gorm:"column:expiration"`
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id;primary_key"`
|
||||
}
|
||||
|
||||
func RefreshTokenViewsToModel(tokens []*RefreshTokenView) []*usr_model.RefreshTokenView {
|
||||
|
@@ -41,7 +41,7 @@ type TokenView struct {
|
||||
RefreshTokenID string `json:"refreshTokenID,omitempty" gorm:"refresh_token_id"`
|
||||
IsPAT bool `json:"-" gorm:"is_pat"`
|
||||
Deactivated bool `json:"-" gorm:"-"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id;primary_key"`
|
||||
}
|
||||
|
||||
func TokenViewToModel(token *TokenView) *usr_model.TokenView {
|
||||
|
@@ -53,7 +53,7 @@ type UserView struct {
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
Type userType `json:"-" gorm:"column:user_type"`
|
||||
UserName string `json:"userName" gorm:"column:user_name"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id;primary_key"`
|
||||
*MachineView
|
||||
*HumanView
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ type UserMembershipView struct {
|
||||
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
||||
ResourceOwnerName string `json:"-" gorm:"column:resource_owner_name"`
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id;primary_key"`
|
||||
}
|
||||
|
||||
func (u *UserMembershipView) AppendEvent(event *models.Event) (err error) {
|
||||
|
@@ -20,6 +20,7 @@ const (
|
||||
UserSessionKeyUserID = "user_id"
|
||||
UserSessionKeyState = "state"
|
||||
UserSessionKeyResourceOwner = "resource_owner"
|
||||
UserSessionKeyInstanceID = "instance_id"
|
||||
)
|
||||
|
||||
type UserSessionView struct {
|
||||
@@ -42,7 +43,7 @@ type UserSessionView struct {
|
||||
MultiFactorVerification time.Time `json:"-" gorm:"column:multi_factor_verification"`
|
||||
MultiFactorVerificationType int32 `json:"-" gorm:"column:multi_factor_verification_type"`
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
|
||||
InstanceID string `json:"instanceID" gorm:"column:instance_id;primary_key"`
|
||||
}
|
||||
|
||||
func UserSessionFromEvent(event *models.Event) (*UserSessionView, error) {
|
||||
|
@@ -59,6 +59,8 @@ func (key UserSessionSearchKey) ToColumnName() string {
|
||||
return UserSessionKeyState
|
||||
case usr_model.UserSessionSearchKeyResourceOwner:
|
||||
return UserSessionKeyResourceOwner
|
||||
case usr_model.UserSessionSearchKeyInstanceID:
|
||||
return UserSessionKeyInstanceID
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
Reference in New Issue
Block a user