mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:47:32 +00:00
refactor: cleanup unused code (#7130)
* refactor: drop unused code * refactor: drop unused code
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type Step int
|
||||
|
||||
const (
|
||||
Step1 Step = iota + 1
|
||||
Step2
|
||||
Step3
|
||||
Step4
|
||||
Step5
|
||||
Step6
|
||||
Step7
|
||||
Step8
|
||||
Step9
|
||||
Step10
|
||||
//StepCount marks the the length of possible steps (StepCount-1 == last possible step)
|
||||
StepCount
|
||||
)
|
||||
|
||||
type IAM struct {
|
||||
es_models.ObjectRoot
|
||||
DefaultOrgID string
|
||||
IAMProjectID string
|
||||
SetUpDone domain.Step
|
||||
SetUpStarted domain.Step
|
||||
Members []*IAMMember
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package model
|
||||
|
||||
import es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
|
||||
type IAMMember struct {
|
||||
es_models.ObjectRoot
|
||||
|
||||
UserID string
|
||||
Roles []string
|
||||
}
|
||||
|
||||
func NewIAMMember(iamID, userID string) *IAMMember {
|
||||
return &IAMMember{ObjectRoot: es_models.ObjectRoot{AggregateID: iamID}, UserID: userID}
|
||||
}
|
||||
|
||||
func (i *IAMMember) IsValid() bool {
|
||||
return i.AggregateID != "" && i.UserID != "" && len(i.Roles) != 0
|
||||
}
|
@@ -1,110 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type IDPConfig struct {
|
||||
es_models.ObjectRoot
|
||||
IDPConfigID string
|
||||
Type IdpConfigType
|
||||
Name string
|
||||
StylingType IDPStylingType
|
||||
State IDPConfigState
|
||||
OIDCConfig *OIDCIDPConfig
|
||||
JWTIDPConfig *JWTIDPConfig
|
||||
}
|
||||
|
||||
type OIDCIDPConfig struct {
|
||||
es_models.ObjectRoot
|
||||
IDPConfigID string
|
||||
ClientID string
|
||||
ClientSecret *crypto.CryptoValue
|
||||
ClientSecretString string
|
||||
Issuer string
|
||||
Scopes []string
|
||||
IDPDisplayNameMapping OIDCMappingField
|
||||
UsernameMapping OIDCMappingField
|
||||
}
|
||||
|
||||
type JWTIDPConfig struct {
|
||||
es_models.ObjectRoot
|
||||
IDPConfigID string
|
||||
JWTEndpoint string
|
||||
Issuer string
|
||||
KeysEndpoint string
|
||||
}
|
||||
|
||||
type IdpConfigType int32
|
||||
|
||||
const (
|
||||
IDPConfigTypeOIDC IdpConfigType = iota
|
||||
IDPConfigTypeSAML
|
||||
IDPConfigTypeJWT
|
||||
)
|
||||
|
||||
type IDPConfigState int32
|
||||
|
||||
const (
|
||||
IDPConfigStateActive IDPConfigState = iota
|
||||
IDPConfigStateInactive
|
||||
IDPConfigStateRemoved
|
||||
)
|
||||
|
||||
type IDPStylingType int32
|
||||
|
||||
const (
|
||||
IDPStylingTypeUnspecified IDPStylingType = iota
|
||||
IDPStylingTypeGoogle
|
||||
)
|
||||
|
||||
type OIDCMappingField int32
|
||||
|
||||
const (
|
||||
OIDCMappingFieldUnspecified OIDCMappingField = iota
|
||||
OIDCMappingFieldPreferredLoginName
|
||||
OIDCMappingFieldEmail
|
||||
)
|
||||
|
||||
func NewIDPConfig(iamID, idpID string) *IDPConfig {
|
||||
return &IDPConfig{ObjectRoot: es_models.ObjectRoot{AggregateID: iamID}, IDPConfigID: idpID}
|
||||
}
|
||||
|
||||
func (idp *IDPConfig) IsValid(includeConfig bool) bool {
|
||||
if idp.Name == "" || idp.AggregateID == "" {
|
||||
return false
|
||||
}
|
||||
if !includeConfig {
|
||||
return true
|
||||
}
|
||||
if idp.Type == IDPConfigTypeOIDC && !idp.OIDCConfig.IsValid(true) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (oi *OIDCIDPConfig) IsValid(withSecret bool) bool {
|
||||
if withSecret {
|
||||
return oi.ClientID != "" && oi.Issuer != "" && oi.ClientSecretString != ""
|
||||
}
|
||||
return oi.ClientID != "" && oi.Issuer != ""
|
||||
}
|
||||
|
||||
func (oi *OIDCIDPConfig) CryptSecret(crypt crypto.Crypto) error {
|
||||
cryptedSecret, err := crypto.Crypt([]byte(oi.ClientSecretString), crypt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
oi.ClientSecret = cryptedSecret
|
||||
return nil
|
||||
}
|
||||
|
||||
func (st IDPStylingType) GetCSSClass() string {
|
||||
switch st {
|
||||
case IDPStylingTypeGoogle:
|
||||
return "google"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type IDPConfigView struct {
|
||||
AggregateID string
|
||||
IDPConfigID string
|
||||
Name string
|
||||
StylingType IDPStylingType
|
||||
AutoRegister bool
|
||||
State IDPConfigState
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
IDPProviderType IDPProviderType
|
||||
|
||||
IsOIDC bool
|
||||
OIDCClientID string
|
||||
OIDCClientSecret *crypto.CryptoValue
|
||||
OIDCIssuer string
|
||||
OIDCScopes []string
|
||||
OIDCIDPDisplayNameMapping OIDCMappingField
|
||||
OIDCUsernameMapping OIDCMappingField
|
||||
OAuthAuthorizationEndpoint string
|
||||
OAuthTokenEndpoint string
|
||||
JWTEndpoint string
|
||||
JWTIssuer string
|
||||
JWTKeysEndpoint string
|
||||
JWTHeaderName string
|
||||
}
|
||||
|
||||
type IDPConfigSearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn IDPConfigSearchKey
|
||||
Asc bool
|
||||
Queries []*IDPConfigSearchQuery
|
||||
}
|
||||
|
||||
type IDPConfigSearchKey int32
|
||||
|
||||
const (
|
||||
IDPConfigSearchKeyUnspecified IDPConfigSearchKey = iota
|
||||
IDPConfigSearchKeyName
|
||||
IDPConfigSearchKeyAggregateID
|
||||
IDPConfigSearchKeyIdpConfigID
|
||||
IDPConfigSearchKeyIdpProviderType
|
||||
IDPConfigSearchKeyInstanceID
|
||||
IDPConfigSearchKeyOwnerRemoved
|
||||
)
|
||||
|
||||
type IDPConfigSearchQuery struct {
|
||||
Key IDPConfigSearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type IDPConfigSearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*IDPConfigView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
func (r *IDPConfigSearchRequest) EnsureLimit(limit uint64) error {
|
||||
if r.Limit > limit {
|
||||
return zerrors.ThrowInvalidArgument(nil, "SEARCH-Mv9sd", "Errors.Limit.ExceedsDefault")
|
||||
}
|
||||
if r.Limit == 0 {
|
||||
r.Limit = limit
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *IDPConfigSearchRequest) AppendMyOrgQuery(orgID, iamID string) {
|
||||
r.Queries = append(r.Queries, &IDPConfigSearchQuery{Key: IDPConfigSearchKeyAggregateID, Method: domain.SearchMethodIsOneOf, Value: []string{orgID, iamID}})
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
type IDPProviderView struct {
|
||||
AggregateID string
|
||||
IDPConfigID string
|
||||
IDPProviderType IDPProviderType
|
||||
Name string
|
||||
StylingType IDPStylingType
|
||||
IDPConfigType IdpConfigType
|
||||
IDPState IDPConfigState
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type IDPProviderSearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn IDPProviderSearchKey
|
||||
Asc bool
|
||||
Queries []*IDPProviderSearchQuery
|
||||
}
|
||||
|
||||
type IDPProviderSearchKey int32
|
||||
|
||||
const (
|
||||
IDPProviderSearchKeyUnspecified IDPProviderSearchKey = iota
|
||||
IDPProviderSearchKeyAggregateID
|
||||
IDPProviderSearchKeyIdpConfigID
|
||||
IDPProviderSearchKeyState
|
||||
IDPProviderSearchKeyInstanceID
|
||||
IDPProviderSearchKeyOwnerRemoved
|
||||
)
|
||||
|
||||
type IDPProviderSearchQuery struct {
|
||||
Key IDPProviderSearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type IDPProviderSearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*IDPProviderView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
func (r *IDPProviderSearchRequest) EnsureLimit(limit uint64) error {
|
||||
if r.Limit > limit {
|
||||
return zerrors.ThrowInvalidArgument(nil, "SEARCH-3n8fs", "Errors.Limit.ExceedsDefault")
|
||||
}
|
||||
if r.Limit == 0 {
|
||||
r.Limit = limit
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *IDPProviderSearchRequest) AppendAggregateIDQuery(aggregateID string) {
|
||||
r.Queries = append(r.Queries, &IDPProviderSearchQuery{Key: IDPProviderSearchKeyAggregateID, Method: domain.SearchMethodEquals, Value: aggregateID})
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type LabelPolicy struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
Default bool
|
||||
PrimaryColor string
|
||||
BackgroundColor string
|
||||
FontColor string
|
||||
WarnColor string
|
||||
PrimaryColorDark string
|
||||
BackgroundColorDark string
|
||||
FontColorDark string
|
||||
WarnColorDark string
|
||||
HideLoginNameSuffix bool
|
||||
}
|
||||
|
||||
func (p *LabelPolicy) IsValid() bool {
|
||||
return p.ObjectRoot.AggregateID != ""
|
||||
}
|
@@ -1,47 +1,9 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
type LabelPolicyView struct {
|
||||
AggregateID string
|
||||
PrimaryColor string
|
||||
BackgroundColor string
|
||||
WarnColor string
|
||||
FontColor string
|
||||
LogoURL string
|
||||
IconURL string
|
||||
|
||||
PrimaryColorDark string
|
||||
BackgroundColorDark string
|
||||
WarnColorDark string
|
||||
FontColorDark string
|
||||
LogoDarkURL string
|
||||
IconDarkURL string
|
||||
FontURL string
|
||||
|
||||
HideLoginNameSuffix bool
|
||||
ErrorMsgPopup bool
|
||||
DisableWatermark bool
|
||||
|
||||
Default bool
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type LabelPolicySearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn LabelPolicySearchKey
|
||||
Asc bool
|
||||
Queries []*LabelPolicySearchQuery
|
||||
}
|
||||
|
||||
type LabelPolicySearchKey int32
|
||||
|
||||
const (
|
||||
@@ -57,12 +19,3 @@ type LabelPolicySearchQuery struct {
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type LabelPolicySearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*LabelPolicyView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
@@ -1,90 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type LoginPolicy struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
Default bool
|
||||
AllowUsernamePassword bool
|
||||
AllowRegister bool
|
||||
AllowExternalIdp bool
|
||||
IDPProviders []*IDPProvider
|
||||
ForceMFA bool
|
||||
SecondFactors []domain.SecondFactorType
|
||||
MultiFactors []domain.MultiFactorType
|
||||
PasswordlessType PasswordlessType
|
||||
}
|
||||
|
||||
type IDPProvider struct {
|
||||
models.ObjectRoot
|
||||
Type IDPProviderType
|
||||
IDPConfigID string
|
||||
}
|
||||
|
||||
type PolicyState int32
|
||||
|
||||
const (
|
||||
PolicyStateActive PolicyState = iota
|
||||
PolicyStateRemoved
|
||||
)
|
||||
|
||||
type IDPProviderType int32
|
||||
|
||||
const (
|
||||
IDPProviderTypeSystem IDPProviderType = iota
|
||||
IDPProviderTypeOrg
|
||||
)
|
||||
|
||||
type MultiFactorType int32
|
||||
|
||||
const (
|
||||
MultiFactorTypeUnspecified MultiFactorType = iota
|
||||
MultiFactorTypeU2FWithPIN
|
||||
)
|
||||
|
||||
type PasswordlessType int32
|
||||
|
||||
const (
|
||||
PasswordlessTypeNotAllowed PasswordlessType = iota
|
||||
PasswordlessTypeAllowed
|
||||
)
|
||||
|
||||
func (p *LoginPolicy) IsValid() bool {
|
||||
return p.ObjectRoot.AggregateID != ""
|
||||
}
|
||||
|
||||
func (p *IDPProvider) IsValid() bool {
|
||||
return p.ObjectRoot.AggregateID != "" && p.IDPConfigID != ""
|
||||
}
|
||||
|
||||
func (p *LoginPolicy) GetIdpProvider(id string) (int, *IDPProvider) {
|
||||
for i, m := range p.IDPProviders {
|
||||
if m.IDPConfigID == id {
|
||||
return i, m
|
||||
}
|
||||
}
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
func (p *LoginPolicy) GetSecondFactor(mfaType domain.SecondFactorType) (int, domain.SecondFactorType) {
|
||||
for i, m := range p.SecondFactors {
|
||||
if m == mfaType {
|
||||
return i, m
|
||||
}
|
||||
}
|
||||
return -1, 0
|
||||
}
|
||||
|
||||
func (p *LoginPolicy) GetMultiFactor(mfaType domain.MultiFactorType) (int, domain.MultiFactorType) {
|
||||
for i, m := range p.MultiFactors {
|
||||
if m == mfaType {
|
||||
return i, m
|
||||
}
|
||||
}
|
||||
return -1, 0
|
||||
}
|
||||
|
@@ -1,129 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type LoginPolicyView struct {
|
||||
AggregateID string
|
||||
AllowUsernamePassword bool
|
||||
AllowRegister bool
|
||||
AllowExternalIDP bool
|
||||
ForceMFA bool
|
||||
HidePasswordReset bool
|
||||
PasswordlessType PasswordlessType
|
||||
SecondFactors []domain.SecondFactorType
|
||||
MultiFactors []domain.MultiFactorType
|
||||
Default bool
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type LoginPolicySearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn LoginPolicySearchKey
|
||||
Asc bool
|
||||
Queries []*LoginPolicySearchQuery
|
||||
}
|
||||
|
||||
type LoginPolicySearchKey int32
|
||||
|
||||
const (
|
||||
LoginPolicySearchKeyUnspecified LoginPolicySearchKey = iota
|
||||
LoginPolicySearchKeyAggregateID
|
||||
LoginPolicySearchKeyDefault
|
||||
)
|
||||
|
||||
type LoginPolicySearchQuery struct {
|
||||
Key LoginPolicySearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type LoginPolicySearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*LoginPolicyView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
||||
func (p *LoginPolicyView) HasSecondFactors() bool {
|
||||
if p.SecondFactors == nil || len(p.SecondFactors) == 0 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *LoginPolicyView) HasMultiFactors() bool {
|
||||
if p.MultiFactors == nil || len(p.MultiFactors) == 0 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *LoginPolicyView) ToLoginPolicyDomain() *domain.LoginPolicy {
|
||||
return &domain.LoginPolicy{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: p.AggregateID,
|
||||
CreationDate: p.CreationDate,
|
||||
ChangeDate: p.ChangeDate,
|
||||
Sequence: p.Sequence,
|
||||
},
|
||||
Default: p.Default,
|
||||
AllowUsernamePassword: p.AllowUsernamePassword,
|
||||
AllowRegister: p.AllowRegister,
|
||||
AllowExternalIDP: p.AllowExternalIDP,
|
||||
ForceMFA: p.ForceMFA,
|
||||
HidePasswordReset: p.HidePasswordReset,
|
||||
PasswordlessType: passwordLessTypeToDomain(p.PasswordlessType),
|
||||
SecondFactors: secondFactorsToDomain(p.SecondFactors),
|
||||
MultiFactors: multiFactorsToDomain(p.MultiFactors),
|
||||
}
|
||||
}
|
||||
|
||||
func passwordLessTypeToDomain(passwordless PasswordlessType) domain.PasswordlessType {
|
||||
switch passwordless {
|
||||
case PasswordlessTypeNotAllowed:
|
||||
return domain.PasswordlessTypeNotAllowed
|
||||
case PasswordlessTypeAllowed:
|
||||
return domain.PasswordlessTypeAllowed
|
||||
default:
|
||||
return domain.PasswordlessTypeNotAllowed
|
||||
}
|
||||
}
|
||||
|
||||
func secondFactorsToDomain(types []domain.SecondFactorType) []domain.SecondFactorType {
|
||||
secondfactors := make([]domain.SecondFactorType, len(types))
|
||||
for i, secondfactorType := range types {
|
||||
switch secondfactorType {
|
||||
case domain.SecondFactorTypeU2F:
|
||||
secondfactors[i] = domain.SecondFactorTypeU2F
|
||||
case domain.SecondFactorTypeTOTP:
|
||||
secondfactors[i] = domain.SecondFactorTypeTOTP
|
||||
case domain.SecondFactorTypeOTPEmail:
|
||||
secondfactors[i] = domain.SecondFactorTypeOTPEmail
|
||||
case domain.SecondFactorTypeOTPSMS:
|
||||
secondfactors[i] = domain.SecondFactorTypeOTPSMS
|
||||
}
|
||||
}
|
||||
return secondfactors
|
||||
}
|
||||
|
||||
func multiFactorsToDomain(types []domain.MultiFactorType) []domain.MultiFactorType {
|
||||
multifactors := make([]domain.MultiFactorType, len(types))
|
||||
for i, multifactorType := range types {
|
||||
switch multifactorType {
|
||||
case domain.MultiFactorTypeU2FWithPIN:
|
||||
multifactors[i] = domain.MultiFactorTypeU2FWithPIN
|
||||
}
|
||||
}
|
||||
return multifactors
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type MailTemplate struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
Default bool
|
||||
Template []byte
|
||||
}
|
||||
|
||||
func (p *MailTemplate) IsValid() bool {
|
||||
return p.ObjectRoot.AggregateID != ""
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type MailTexts struct {
|
||||
Texts []*MailText
|
||||
Default bool
|
||||
}
|
||||
type MailText struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
Default bool
|
||||
MailTextType string
|
||||
Language string
|
||||
Title string
|
||||
PreHeader string
|
||||
Subject string
|
||||
Greeting string
|
||||
Text string
|
||||
ButtonText string
|
||||
FooterText string
|
||||
}
|
||||
|
||||
func (p *MailText) IsValid() bool {
|
||||
return p.ObjectRoot.AggregateID != ""
|
||||
}
|
@@ -1,59 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
type MessageTextView struct {
|
||||
AggregateID string
|
||||
MessageTextType string
|
||||
Language language.Tag
|
||||
Title string
|
||||
PreHeader string
|
||||
Subject string
|
||||
Greeting string
|
||||
Text string
|
||||
ButtonText string
|
||||
FooterText string
|
||||
Default bool
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type MessageTextSearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn MessageTextSearchKey
|
||||
Asc bool
|
||||
Queries []*MessageTextSearchQuery
|
||||
}
|
||||
|
||||
type MessageTextSearchKey int32
|
||||
|
||||
const (
|
||||
MessageTextSearchKeyUnspecified MessageTextSearchKey = iota
|
||||
MessageTextSearchKeyAggregateID
|
||||
MessageTextSearchKeyMessageTextType
|
||||
MessageTextSearchKeyLanguage
|
||||
)
|
||||
|
||||
type MessageTextSearchQuery struct {
|
||||
Key MessageTextSearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type MessageTextSearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*MessageTextView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
@@ -1,47 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
type SecondFactorsSearchRequest struct {
|
||||
Queries []*MFASearchQuery
|
||||
}
|
||||
|
||||
type MultiFactorsSearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
Asc bool
|
||||
Queries []*MFASearchQuery
|
||||
}
|
||||
|
||||
type MFASearchQuery struct {
|
||||
Key MFASearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type MFASearchKey int32
|
||||
|
||||
const (
|
||||
MFASearchKeyUnspecified MFASearchKey = iota
|
||||
MFASearchKeyAggregateID
|
||||
)
|
||||
|
||||
type SecondFactorsSearchResponse struct {
|
||||
TotalResult uint64
|
||||
Result []domain.SecondFactorType
|
||||
}
|
||||
|
||||
type MultiFactorsSearchResponse struct {
|
||||
TotalResult uint64
|
||||
Result []domain.MultiFactorType
|
||||
}
|
||||
|
||||
func (r *SecondFactorsSearchRequest) AppendAggregateIDQuery(aggregateID string) {
|
||||
r.Queries = append(r.Queries, &MFASearchQuery{Key: MFASearchKeyAggregateID, Method: domain.SearchMethodEquals, Value: aggregateID})
|
||||
}
|
||||
|
||||
func (r *MultiFactorsSearchRequest) AppendAggregateIDQuery(aggregateID string) {
|
||||
r.Queries = append(r.Queries, &MFASearchQuery{Key: MFASearchKeyAggregateID, Method: domain.SearchMethodEquals, Value: aggregateID})
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type PasswordAgePolicy struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
MaxAgeDays uint64
|
||||
ExpireWarnDays uint64
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
type PasswordAgePolicyView struct {
|
||||
AggregateID string
|
||||
MaxAgeDays uint64
|
||||
ExpireWarnDays uint64
|
||||
Default bool
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type PasswordAgePolicySearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn PasswordAgePolicySearchKey
|
||||
Asc bool
|
||||
Queries []*PasswordAgePolicySearchQuery
|
||||
}
|
||||
|
||||
type PasswordAgePolicySearchKey int32
|
||||
|
||||
const (
|
||||
PasswordAgePolicySearchKeyUnspecified PasswordAgePolicySearchKey = iota
|
||||
PasswordAgePolicySearchKeyAggregateID
|
||||
)
|
||||
|
||||
type PasswordAgePolicySearchQuery struct {
|
||||
Key PasswordAgePolicySearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type PasswordAgePolicySearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*PasswordAgePolicyView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
@@ -1,58 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
var (
|
||||
hasStringLowerCase = regexp.MustCompile(`[a-z]`).MatchString
|
||||
hasStringUpperCase = regexp.MustCompile(`[A-Z]`).MatchString
|
||||
hasNumber = regexp.MustCompile(`[0-9]`).MatchString
|
||||
hasSymbol = regexp.MustCompile(`[^A-Za-z0-9]`).MatchString
|
||||
)
|
||||
|
||||
type PasswordComplexityPolicy struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
MinLength uint64
|
||||
HasLowercase bool
|
||||
HasUppercase bool
|
||||
HasNumber bool
|
||||
HasSymbol bool
|
||||
|
||||
Default bool
|
||||
}
|
||||
|
||||
func (p *PasswordComplexityPolicy) IsValid() error {
|
||||
if p.MinLength == 0 || p.MinLength > 72 {
|
||||
return zerrors.ThrowInvalidArgument(nil, "MODEL-Lsp0e", "Errors.User.PasswordComplexityPolicy.MinLengthNotAllowed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PasswordComplexityPolicy) Check(password string) error {
|
||||
if p.MinLength != 0 && uint64(len(password)) < p.MinLength {
|
||||
return zerrors.ThrowInvalidArgument(nil, "MODEL-HuJf6", "Errors.User.PasswordComplexityPolicy.MinLength")
|
||||
}
|
||||
|
||||
if p.HasLowercase && !hasStringLowerCase(password) {
|
||||
return zerrors.ThrowInvalidArgument(nil, "MODEL-co3Xw", "Errors.User.PasswordComplexityPolicy.HasLower")
|
||||
}
|
||||
|
||||
if p.HasUppercase && !hasStringUpperCase(password) {
|
||||
return zerrors.ThrowInvalidArgument(nil, "MODEL-VoaRj", "Errors.User.PasswordComplexityPolicy.HasUpper")
|
||||
}
|
||||
|
||||
if p.HasNumber && !hasNumber(password) {
|
||||
return zerrors.ThrowInvalidArgument(nil, "MODEL-ZBv4H", "Errors.User.PasswordComplexityPolicy.HasNumber")
|
||||
}
|
||||
|
||||
if p.HasSymbol && !hasSymbol(password) {
|
||||
return zerrors.ThrowInvalidArgument(nil, "MODEL-ZDLwA", "Errors.User.PasswordComplexityPolicy.HasSymbol")
|
||||
}
|
||||
return nil
|
||||
}
|
@@ -2,8 +2,6 @@ package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
type PasswordComplexityPolicyView struct {
|
||||
@@ -19,33 +17,3 @@ type PasswordComplexityPolicyView struct {
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type PasswordComplexityPolicySearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn PasswordComplexityPolicySearchKey
|
||||
Asc bool
|
||||
Queries []*PasswordComplexityPolicySearchQuery
|
||||
}
|
||||
|
||||
type PasswordComplexityPolicySearchKey int32
|
||||
|
||||
const (
|
||||
PasswordComplexityPolicySearchKeyUnspecified PasswordComplexityPolicySearchKey = iota
|
||||
PasswordComplexityPolicySearchKeyAggregateID
|
||||
)
|
||||
|
||||
type PasswordComplexityPolicySearchQuery struct {
|
||||
Key PasswordComplexityPolicySearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type PasswordComplexityPolicySearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*PasswordComplexityPolicyView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
||||
|
@@ -1,13 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
)
|
||||
|
||||
type LockoutPolicy struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State PolicyState
|
||||
MaxPasswordAttempts uint64
|
||||
ShowLockOutFailures bool
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
type LockoutPolicyView struct {
|
||||
AggregateID string
|
||||
MaxPasswordAttempts uint64
|
||||
ShowLockOutFailures bool
|
||||
Default bool
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type LockoutPolicySearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn LockoutPolicySearchKey
|
||||
Asc bool
|
||||
Queries []*LockoutPolicySearchQuery
|
||||
}
|
||||
|
||||
type LockoutPolicySearchKey int32
|
||||
|
||||
const (
|
||||
LockoutPolicySearchKeyUnspecified LockoutPolicySearchKey = iota
|
||||
LockoutPolicySearchKeyAggregateID
|
||||
)
|
||||
|
||||
type LockoutPolicySearchQuery struct {
|
||||
Key LockoutPolicySearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type LockoutPolicySearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*LockoutPolicyView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
)
|
||||
|
||||
type PrivacyPolicyView struct {
|
||||
AggregateID string
|
||||
TOSLink string
|
||||
PrivacyLink string
|
||||
SupportEmail string
|
||||
Default bool
|
||||
|
||||
CreationDate time.Time
|
||||
ChangeDate time.Time
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
type PrivacyPolicySearchRequest struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
SortingColumn PrivacyPolicySearchKey
|
||||
Asc bool
|
||||
Queries []*PrivacyPolicySearchQuery
|
||||
}
|
||||
|
||||
type PrivacyPolicySearchKey int32
|
||||
|
||||
const (
|
||||
PrivacyPolicySearchKeyUnspecified PrivacyPolicySearchKey = iota
|
||||
PrivacyPolicySearchKeyAggregateID
|
||||
)
|
||||
|
||||
type PrivacyPolicySearchQuery struct {
|
||||
Key PrivacyPolicySearchKey
|
||||
Method domain.SearchMethod
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
type PrivacyPolicySearchResponse struct {
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
TotalResult uint64
|
||||
Result []*PrivacyPolicyView
|
||||
Sequence uint64
|
||||
Timestamp time.Time
|
||||
}
|
Reference in New Issue
Block a user