mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
chore: rename IAM to instance (#11351)
# Which Problems Are Solved In many cases IAM was used where instance was meant. # How the Problems Are Solved - Rename wrong usage of IAM to instance all over the code base. - Add an agents.md which explains the terms used in Zitadel's architecture. # Additional Context - closes #11280 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: muhlemmer <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Marco A. <[email protected]>
This commit is contained in:
co-authored by
Copilot
muhlemmer
Copilot
Marco A.
parent
67a02a6aeb
commit
5a2181bcec
@@ -37,14 +37,14 @@ func (c *Commands) SetCustomInstanceLoginText(ctx context.Context, loginText *do
|
||||
|
||||
func (c *Commands) RemoveCustomInstanceLoginTexts(ctx context.Context, lang language.Tag) (*domain.ObjectDetails, error) {
|
||||
if lang == language.Und {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "IAM-Gfbg3", "Errors.CustomText.Invalid")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INST-Gfbg3", "Errors.CustomText.Invalid")
|
||||
}
|
||||
customText, err := c.defaultLoginTextWriteModelByID(ctx, lang)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if customText.State == domain.PolicyStateUnspecified || customText.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "IAM-fru44", "Errors.CustomText.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INST-fru44", "Errors.CustomText.NotFound")
|
||||
}
|
||||
iamAgg := InstanceAggregateFromWriteModel(&customText.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, instance.NewCustomTextTemplateRemovedEvent(ctx, iamAgg, domain.LoginCustomText, lang))
|
||||
|
||||
@@ -35,7 +35,7 @@ func (c *Commands) addDefaultDebugNotificationFile(ctx context.Context, instance
|
||||
return nil, err
|
||||
}
|
||||
if addedWriteModel.State.Exists() {
|
||||
return nil, zerrors.ThrowAlreadyExists(nil, "INSTANCE-d93nfs", "Errors.IAM.DebugNotificationProvider.AlreadyExists")
|
||||
return nil, zerrors.ThrowAlreadyExists(nil, "INSTANCE-d93nfs", "Errors.Instance.DebugNotificationProvider.AlreadyExists")
|
||||
}
|
||||
|
||||
events := []eventstore.Command{
|
||||
@@ -70,7 +70,7 @@ func (c *Commands) changeDefaultDebugNotificationProviderFile(ctx context.Contex
|
||||
return nil, err
|
||||
}
|
||||
if !existingProvider.State.Exists() {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-fm9wl", "Errors.IAM.DebugNotificationProvider.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-fm9wl", "Errors.Instance.DebugNotificationProvider.NotFound")
|
||||
}
|
||||
events := make([]eventstore.Command, 0)
|
||||
changedEvent, hasChanged := existingProvider.NewChangedEvent(ctx,
|
||||
@@ -80,7 +80,7 @@ func (c *Commands) changeDefaultDebugNotificationProviderFile(ctx context.Contex
|
||||
events = append(events, changedEvent)
|
||||
}
|
||||
if len(events) == 0 {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-5M9vdd", "Errors.IAM.LoginPolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-5M9vdd", "Errors.Instance.LoginPolicy.NotChanged")
|
||||
|
||||
}
|
||||
return events, nil
|
||||
@@ -94,7 +94,7 @@ func (c *Commands) RemoveDefaultNotificationFile(ctx context.Context) (*domain.O
|
||||
return nil, err
|
||||
}
|
||||
if !existingProvider.State.Exists() {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-dj9ew", "Errors.IAM.DebugNotificationProvider.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-dj9ew", "Errors.Instance.DebugNotificationProvider.NotFound")
|
||||
}
|
||||
|
||||
events, err := c.eventstore.Push(ctx, iam_repo.NewDebugNotificationProviderFileRemovedEvent(ctx, instanceAgg))
|
||||
|
||||
@@ -35,7 +35,7 @@ func (c *Commands) addDefaultDebugNotificationLog(ctx context.Context, instanceA
|
||||
return nil, err
|
||||
}
|
||||
if addedWriteModel.State.Exists() {
|
||||
return nil, zerrors.ThrowAlreadyExists(nil, "INSTANCE-3h0fs", "Errors.IAM.DebugNotificationProvider.AlreadyExists")
|
||||
return nil, zerrors.ThrowAlreadyExists(nil, "INSTANCE-3h0fs", "Errors.Instance.DebugNotificationProvider.AlreadyExists")
|
||||
}
|
||||
|
||||
events := []eventstore.Command{
|
||||
@@ -70,13 +70,13 @@ func (c *Commands) changeDefaultDebugNotificationProviderLog(ctx context.Context
|
||||
return nil, err
|
||||
}
|
||||
if !existingProvider.State.Exists() {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-2h0s3", "Errors.IAM.DebugNotificationProvider.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-2h0s3", "Errors.Instance.DebugNotificationProvider.NotFound")
|
||||
}
|
||||
changedEvent, hasChanged := existingProvider.NewChangedEvent(ctx,
|
||||
instanceAgg,
|
||||
fileSystemProvider.Compact)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-fn9p3", "Errors.IAM.LoginPolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-fn9p3", "Errors.Instance.LoginPolicy.NotChanged")
|
||||
}
|
||||
return changedEvent, nil
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func (c *Commands) RemoveDefaultNotificationLog(ctx context.Context) (*domain.Ob
|
||||
return nil, err
|
||||
}
|
||||
if !existingProvider.State.Exists() {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-39lse", "Errors.IAM.DebugNotificationProvider.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-39lse", "Errors.Instance.DebugNotificationProvider.NotFound")
|
||||
}
|
||||
|
||||
events, err := c.eventstore.Push(ctx, instance.NewDebugNotificationProviderLogRemovedEvent(ctx, instanceAgg))
|
||||
|
||||
@@ -90,7 +90,7 @@ func (c *Commands) ChangeDefaultIDPConfig(ctx context.Context, config *domain.ID
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingIDP.WriteModel)
|
||||
changedEvent, hasChanged := existingIDP.NewChangedEvent(ctx, instanceAgg, config.IDPConfigID, config.Name, config.StylingType, config.AutoRegister)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-3k0fs", "Errors.IAM.IDPConfig.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-3k0fs", "Errors.Instance.IDPConfig.NotChanged")
|
||||
}
|
||||
pushedEvents, err := c.eventstore.Push(ctx, changedEvent)
|
||||
if err != nil {
|
||||
@@ -109,7 +109,7 @@ func (c *Commands) DeactivateDefaultIDPConfig(ctx context.Context, idpID string)
|
||||
return nil, err
|
||||
}
|
||||
if existingIDP.State != domain.IDPConfigStateActive {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-2n0fs", "Errors.IAM.IDPConfig.NotActive")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-2n0fs", "Errors.Instance.IDPConfig.NotActive")
|
||||
}
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingIDP.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, instance.NewIDPConfigDeactivatedEvent(ctx, instanceAgg, idpID))
|
||||
@@ -129,7 +129,7 @@ func (c *Commands) ReactivateDefaultIDPConfig(ctx context.Context, idpID string)
|
||||
return nil, err
|
||||
}
|
||||
if existingIDP.State != domain.IDPConfigStateInactive {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-5Mo0d", "Errors.IAM.IDPConfig.NotInactive")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-5Mo0d", "Errors.Instance.IDPConfig.NotInactive")
|
||||
}
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingIDP.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, instance.NewIDPConfigReactivatedEvent(ctx, instanceAgg, idpID))
|
||||
|
||||
@@ -18,7 +18,7 @@ func (c *Commands) ChangeDefaultIDPJWTConfig(ctx context.Context, config *domain
|
||||
}
|
||||
|
||||
if existingConfig.State == domain.IDPConfigStateRemoved || existingConfig.State == domain.IDPConfigStateUnspecified {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-2m00d", "Errors.IAM.IDPConfig.AlreadyExists")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-2m00d", "Errors.Instance.IDPConfig.AlreadyExists")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingConfig.WriteModel)
|
||||
@@ -34,7 +34,7 @@ func (c *Commands) ChangeDefaultIDPJWTConfig(ctx context.Context, config *domain
|
||||
return nil, err
|
||||
}
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-3n9gg", "Errors.IAM.IDPConfig.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-3n9gg", "Errors.Instance.IDPConfig.NotChanged")
|
||||
}
|
||||
|
||||
pushedEvents, err := c.eventstore.Push(ctx, changedEvent)
|
||||
|
||||
@@ -18,7 +18,7 @@ func (c *Commands) ChangeDefaultIDPOIDCConfig(ctx context.Context, config *domai
|
||||
}
|
||||
|
||||
if existingConfig.State == domain.IDPConfigStateRemoved || existingConfig.State == domain.IDPConfigStateUnspecified {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-67J9d", "Errors.IAM.IDPConfig.AlreadyExists")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-67J9d", "Errors.Instance.IDPConfig.AlreadyExists")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingConfig.WriteModel)
|
||||
@@ -39,7 +39,7 @@ func (c *Commands) ChangeDefaultIDPOIDCConfig(ctx context.Context, config *domai
|
||||
return nil, err
|
||||
}
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-d8kwF", "Errors.IAM.IDPConfig.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-d8kwF", "Errors.Instance.IDPConfig.NotChanged")
|
||||
}
|
||||
|
||||
pushedEvents, err := c.eventstore.Push(ctx, changedEvent)
|
||||
|
||||
@@ -19,7 +19,7 @@ func (c *Commands) AddInstanceMemberCommand(a *instance.Aggregate, userID string
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTA-SDSfs", "Errors.Invalid.Argument")
|
||||
}
|
||||
if len(domain.CheckForInvalidRoles(roles, domain.IAMRolePrefix, c.zitadelRoles)) > 0 {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-4m0fS", "Errors.IAM.MemberInvalid")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-4m0fS", "Errors.Instance.MemberInvalid")
|
||||
}
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
if exists, err := ExistsUser(ctx, filter, userID, "", false); err != nil || !exists {
|
||||
@@ -105,10 +105,10 @@ type ChangeInstanceMember struct {
|
||||
|
||||
func (i *ChangeInstanceMember) IsValid(zitadelRoles []authz.RoleMapping) error {
|
||||
if i.InstanceID == "" || i.UserID == "" || len(i.Roles) == 0 {
|
||||
return zerrors.ThrowInvalidArgument(nil, "INSTANCE-LiaZi", "Errors.IAM.MemberInvalid")
|
||||
return zerrors.ThrowInvalidArgument(nil, "INSTANCE-LiaZi", "Errors.Instance.MemberInvalid")
|
||||
}
|
||||
if len(domain.CheckForInvalidRoles(i.Roles, domain.IAMRolePrefix, zitadelRoles)) > 0 {
|
||||
return zerrors.ThrowInvalidArgument(nil, "INSTANCE-3m9fs", "Errors.IAM.MemberInvalid")
|
||||
return zerrors.ThrowInvalidArgument(nil, "INSTANCE-3m9fs", "Errors.Instance.MemberInvalid")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func (c *Commands) getDefaultDomainPolicy(ctx context.Context) (*domain.DomainPo
|
||||
return nil, err
|
||||
}
|
||||
if !policyWriteModel.State.Exists() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-3n8fs", "Errors.IAM.PasswordComplexityPolicy.NotFound")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-3n8fs", "Errors.Instance.PasswordComplexityPolicy.NotFound")
|
||||
}
|
||||
policy := writeModelToDomainPolicy(policyWriteModel)
|
||||
policy.Default = true
|
||||
|
||||
@@ -72,7 +72,7 @@ func (wm *InstanceDomainPolicyWriteModel) NewChangedEvent(
|
||||
changes = append(changes, policy.ChangeSMTPSenderAddressMatchesInstanceDomain(smtpSenderAddresssMatchesInstanceDomain))
|
||||
}
|
||||
if len(changes) == 0 {
|
||||
return nil, false, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-pl9fN", "Errors.IAM.DomainPolicy.NotChanged")
|
||||
return nil, false, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-pl9fN", "Errors.Instance.DomainPolicy.NotChanged")
|
||||
}
|
||||
changedEvent, err = instance.NewDomainPolicyChangedEvent(ctx, aggregate, changes)
|
||||
return changedEvent, usernameChange, err
|
||||
|
||||
@@ -22,7 +22,7 @@ func (c *Commands) ChangeDefaultLabelPolicy(ctx context.Context, policy *domain.
|
||||
}
|
||||
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0K9dq", "Errors.IAM.LabelPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0K9dq", "Errors.Instance.LabelPolicy.NotFound")
|
||||
}
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingPolicy.LabelPolicyWriteModel.WriteModel)
|
||||
changedEvent, hasChanged := existingPolicy.NewChangedEvent(
|
||||
@@ -41,7 +41,7 @@ func (c *Commands) ChangeDefaultLabelPolicy(ctx context.Context, policy *domain.
|
||||
policy.DisableWatermark,
|
||||
policy.ThemeMode)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-28fHe", "Errors.IAM.LabelPolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-28fHe", "Errors.Instance.LabelPolicy.NotChanged")
|
||||
}
|
||||
|
||||
pushedEvents, err := c.eventstore.Push(ctx, changedEvent)
|
||||
@@ -75,7 +75,7 @@ func (c *Commands) AddLogoDefaultLabelPolicy(ctx context.Context, upload *AssetU
|
||||
}
|
||||
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-Qw0pd", "Errors.IAM.LabelPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-Qw0pd", "Errors.Instance.LabelPolicy.NotFound")
|
||||
}
|
||||
asset, err := c.uploadAsset(ctx, upload)
|
||||
if err != nil {
|
||||
@@ -100,7 +100,7 @@ func (c *Commands) RemoveLogoDefaultLabelPolicy(ctx context.Context) (*domain.Ob
|
||||
}
|
||||
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-Xc8Kf", "Errors.IAM.LabelPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-Xc8Kf", "Errors.Instance.LabelPolicy.NotFound")
|
||||
}
|
||||
|
||||
err = c.removeAsset(ctx, authz.GetInstance(ctx).InstanceID(), existingPolicy.LogoKey)
|
||||
@@ -126,7 +126,7 @@ func (c *Commands) AddIconDefaultLabelPolicy(ctx context.Context, upload *AssetU
|
||||
}
|
||||
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-1yMx0", "Errors.IAM.LabelPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-1yMx0", "Errors.Instance.LabelPolicy.NotFound")
|
||||
}
|
||||
asset, err := c.uploadAsset(ctx, upload)
|
||||
if err != nil {
|
||||
@@ -151,7 +151,7 @@ func (c *Commands) RemoveIconDefaultLabelPolicy(ctx context.Context) (*domain.Ob
|
||||
}
|
||||
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-4M0qw", "Errors.IAM.LabelPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-4M0qw", "Errors.Instance.LabelPolicy.NotFound")
|
||||
}
|
||||
err = c.removeAsset(ctx, authz.GetInstance(ctx).InstanceID(), existingPolicy.IconKey)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,7 +30,7 @@ func (c *Commands) ChangeDefaultLoginPolicy(ctx context.Context, policy *ChangeL
|
||||
|
||||
func (c *Commands) AddIDPProviderToDefaultLoginPolicy(ctx context.Context, idpProvider *domain.IDPProvider) (*domain.IDPProvider, error) {
|
||||
if !idpProvider.IsValid() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-9nf88", "Errors.IAM.LoginPolicy.IDP.Invalid")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-9nf88", "Errors.Instance.LoginPolicy.IDP.Invalid")
|
||||
}
|
||||
existingPolicy := NewInstanceLoginPolicyWriteModel(ctx)
|
||||
err := c.defaultLoginPolicyWriteModelByID(ctx, existingPolicy)
|
||||
@@ -38,7 +38,7 @@ func (c *Commands) AddIDPProviderToDefaultLoginPolicy(ctx context.Context, idpPr
|
||||
return nil, err
|
||||
}
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-GVDfe", "Errors.IAM.LoginPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-GVDfe", "Errors.Instance.LoginPolicy.NotFound")
|
||||
}
|
||||
|
||||
exists, err := ExistsInstanceIDP(ctx, c.eventstore.Filter, idpProvider.IDPConfigID)
|
||||
@@ -51,7 +51,7 @@ func (c *Commands) AddIDPProviderToDefaultLoginPolicy(ctx context.Context, idpPr
|
||||
return nil, err
|
||||
}
|
||||
if idpModel.State == domain.IdentityProviderStateActive {
|
||||
return nil, zerrors.ThrowAlreadyExists(nil, "INSTANCE-2B0ps", "Errors.IAM.LoginPolicy.IDP.AlreadyExists")
|
||||
return nil, zerrors.ThrowAlreadyExists(nil, "INSTANCE-2B0ps", "Errors.Instance.LoginPolicy.IDP.AlreadyExists")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&idpModel.WriteModel)
|
||||
@@ -68,7 +68,7 @@ func (c *Commands) AddIDPProviderToDefaultLoginPolicy(ctx context.Context, idpPr
|
||||
|
||||
func (c *Commands) RemoveIDPProviderFromDefaultLoginPolicy(ctx context.Context, idpProvider *domain.IDPProvider) (*domain.ObjectDetails, error) {
|
||||
if !idpProvider.IsValid() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-66m9s", "Errors.IAM.LoginPolicy.IDP.Invalid")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-66m9s", "Errors.Instance.LoginPolicy.IDP.Invalid")
|
||||
}
|
||||
existingPolicy := NewInstanceLoginPolicyWriteModel(ctx)
|
||||
err := c.defaultLoginPolicyWriteModelByID(ctx, existingPolicy)
|
||||
@@ -76,7 +76,7 @@ func (c *Commands) RemoveIDPProviderFromDefaultLoginPolicy(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-Dfg4t", "Errors.IAM.LoginPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-Dfg4t", "Errors.Instance.LoginPolicy.NotFound")
|
||||
}
|
||||
|
||||
idpModel := NewInstanceIdentityProviderWriteModel(ctx, idpProvider.IDPConfigID)
|
||||
@@ -85,7 +85,7 @@ func (c *Commands) RemoveIDPProviderFromDefaultLoginPolicy(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
if idpModel.State == domain.IdentityProviderStateUnspecified || idpModel.State == domain.IdentityProviderStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-39fjs", "Errors.IAM.LoginPolicy.IDP.NotExisting")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-39fjs", "Errors.Instance.LoginPolicy.IDP.NotExisting")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&idpModel.IdentityProviderWriteModel.WriteModel)
|
||||
@@ -135,7 +135,7 @@ func (c *Commands) AddSecondFactorToDefaultLoginPolicy(ctx context.Context, seco
|
||||
|
||||
func (c *Commands) RemoveSecondFactorFromDefaultLoginPolicy(ctx context.Context, secondFactor domain.SecondFactorType) (*domain.ObjectDetails, error) {
|
||||
if !secondFactor.Valid() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-55n8s", "Errors.IAM.LoginPolicy.MFA.Unspecified")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-55n8s", "Errors.Instance.LoginPolicy.MFA.Unspecified")
|
||||
}
|
||||
secondFactorModel := NewInstanceSecondFactorWriteModel(ctx, secondFactor)
|
||||
err := c.eventstore.FilterToQueryReducer(ctx, secondFactorModel)
|
||||
@@ -143,7 +143,7 @@ func (c *Commands) RemoveSecondFactorFromDefaultLoginPolicy(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
if secondFactorModel.State == domain.FactorStateUnspecified || secondFactorModel.State == domain.FactorStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-3M9od", "Errors.IAM.LoginPolicy.MFA.NotExisting")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-3M9od", "Errors.Instance.LoginPolicy.MFA.NotExisting")
|
||||
}
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&secondFactorModel.SecondFactorWriteModel.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, instance.NewLoginPolicySecondFactorRemovedEvent(ctx, instanceAgg, secondFactor))
|
||||
@@ -172,7 +172,7 @@ func (c *Commands) AddMultiFactorToDefaultLoginPolicy(ctx context.Context, multi
|
||||
|
||||
func (c *Commands) RemoveMultiFactorFromDefaultLoginPolicy(ctx context.Context, multiFactor domain.MultiFactorType) (*domain.ObjectDetails, error) {
|
||||
if !multiFactor.Valid() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-33m9F", "Errors.IAM.LoginPolicy.MFA.Unspecified")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-33m9F", "Errors.Instance.LoginPolicy.MFA.Unspecified")
|
||||
}
|
||||
multiFactorModel := NewInstanceMultiFactorWriteModel(ctx, multiFactor)
|
||||
err := c.eventstore.FilterToQueryReducer(ctx, multiFactorModel)
|
||||
@@ -180,7 +180,7 @@ func (c *Commands) RemoveMultiFactorFromDefaultLoginPolicy(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
if multiFactorModel.State == domain.FactorStateUnspecified || multiFactorModel.State == domain.FactorStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-3M9df", "Errors.IAM.LoginPolicy.MFA.NotExisting")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-3M9df", "Errors.Instance.LoginPolicy.MFA.NotExisting")
|
||||
}
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&multiFactorModel.MultiFactorWriteModel.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, instance.NewLoginPolicyMultiFactorRemovedEvent(ctx, instanceAgg, multiFactor))
|
||||
@@ -215,7 +215,7 @@ func (c *Commands) getDefaultLoginPolicy(ctx context.Context) (*domain.LoginPoli
|
||||
func prepareChangeDefaultLoginPolicy(a *instance.Aggregate, policy *ChangeLoginPolicy) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
if ok := domain.ValidateDefaultRedirectURI(policy.DefaultRedirectURI); !ok {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "IAM-SFdqd", "Errors.IAM.LoginPolicy.RedirectURIInvalid")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INST-SFdqd", "Errors.Instance.LoginPolicy.RedirectURIInvalid")
|
||||
}
|
||||
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
||||
wm := NewInstanceLoginPolicyWriteModel(ctx)
|
||||
@@ -223,7 +223,7 @@ func prepareChangeDefaultLoginPolicy(a *instance.Aggregate, policy *ChangeLoginP
|
||||
return nil, err
|
||||
}
|
||||
if !wm.State.Exists() {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-M0sif", "Errors.IAM.LoginPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-M0sif", "Errors.Instance.LoginPolicy.NotFound")
|
||||
}
|
||||
changedEvent, hasChanged := wm.NewChangedEvent(ctx, &a.Aggregate,
|
||||
policy.AllowUsernamePassword,
|
||||
@@ -244,7 +244,7 @@ func prepareChangeDefaultLoginPolicy(a *instance.Aggregate, policy *ChangeLoginP
|
||||
policy.SecondFactorCheckLifetime,
|
||||
policy.MultiFactorCheckLifetime)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-5M9vdd", "Errors.IAM.LoginPolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-5M9vdd", "Errors.Instance.LoginPolicy.NotChanged")
|
||||
}
|
||||
return []eventstore.Command{changedEvent}, nil
|
||||
}, nil
|
||||
|
||||
@@ -32,14 +32,14 @@ func (c *Commands) AddDefaultMailTemplate(ctx context.Context, policy *domain.Ma
|
||||
|
||||
func (c *Commands) addDefaultMailTemplate(ctx context.Context, instanceAgg *eventstore.Aggregate, addedPolicy *InstanceMailTemplateWriteModel, policy *domain.MailTemplate) (eventstore.Command, error) {
|
||||
if !policy.IsValid() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-fm9sd", "Errors.IAM.MailTemplate.Invalid")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-fm9sd", "Errors.Instance.MailTemplate.Invalid")
|
||||
}
|
||||
err := c.eventstore.FilterToQueryReducer(ctx, addedPolicy)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if addedPolicy.State == domain.PolicyStateActive {
|
||||
return nil, zerrors.ThrowAlreadyExists(nil, "INSTANCE-5n8fs", "Errors.IAM.MailTemplate.AlreadyExists")
|
||||
return nil, zerrors.ThrowAlreadyExists(nil, "INSTANCE-5n8fs", "Errors.Instance.MailTemplate.AlreadyExists")
|
||||
}
|
||||
|
||||
return instance.NewMailTemplateAddedEvent(ctx, instanceAgg, policy.Template), nil
|
||||
@@ -63,7 +63,7 @@ func (c *Commands) ChangeDefaultMailTemplate(ctx context.Context, policy *domain
|
||||
|
||||
func (c *Commands) changeDefaultMailTemplate(ctx context.Context, policy *domain.MailTemplate) (*InstanceMailTemplateWriteModel, eventstore.Command, error) {
|
||||
if !policy.IsValid() {
|
||||
return nil, nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-4m9ds", "Errors.IAM.MailTemplate.Invalid")
|
||||
return nil, nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-4m9ds", "Errors.Instance.MailTemplate.Invalid")
|
||||
}
|
||||
existingPolicy, err := c.defaultMailTemplateWriteModelByID(ctx)
|
||||
if err != nil {
|
||||
@@ -71,13 +71,13 @@ func (c *Commands) changeDefaultMailTemplate(ctx context.Context, policy *domain
|
||||
}
|
||||
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, nil, zerrors.ThrowNotFound(nil, "INSTANCE-2N8fs", "Errors.IAM.MailTemplate.NotFound")
|
||||
return nil, nil, zerrors.ThrowNotFound(nil, "INSTANCE-2N8fs", "Errors.Instance.MailTemplate.NotFound")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingPolicy.MailTemplateWriteModel.WriteModel)
|
||||
changedEvent, hasChanged := existingPolicy.NewChangedEvent(ctx, instanceAgg, policy.Template)
|
||||
if !hasChanged {
|
||||
return nil, nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-3nfsG", "Errors.IAM.MailTemplate.NotChanged")
|
||||
return nil, nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-3nfsG", "Errors.Instance.MailTemplate.NotChanged")
|
||||
}
|
||||
|
||||
return existingPolicy, changedEvent, nil
|
||||
|
||||
@@ -78,11 +78,11 @@ func prepareChangeDefaultNotificationPolicy(
|
||||
}
|
||||
|
||||
if writeModel.State == domain.PolicyStateUnspecified || writeModel.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-x891na", "Errors.IAM.NotificationPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-x891na", "Errors.Instance.NotificationPolicy.NotFound")
|
||||
}
|
||||
change, hasChanged := writeModel.NewChangedEvent(ctx, &a.Aggregate, passwordChange)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-29x02n", "Errors.IAM.NotificationPolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-29x02n", "Errors.Instance.NotificationPolicy.NotChanged")
|
||||
}
|
||||
return []eventstore.Command{
|
||||
change,
|
||||
|
||||
@@ -31,13 +31,13 @@ func (c *Commands) ChangeDefaultPasswordAgePolicy(ctx context.Context, policy *d
|
||||
return nil, err
|
||||
}
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0oPew", "Errors.IAM.PasswordAgePolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0oPew", "Errors.Instance.PasswordAgePolicy.NotFound")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingPolicy.PasswordAgePolicyWriteModel.WriteModel)
|
||||
changedEvent, hasChanged := existingPolicy.NewChangedEvent(ctx, instanceAgg, policy.ExpireWarnDays, policy.MaxAgeDays)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-180sf", "Errors.IAM.PasswordAgePolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-180sf", "Errors.Instance.PasswordAgePolicy.NotChanged")
|
||||
}
|
||||
|
||||
pushedEvents, err := c.eventstore.Push(ctx, changedEvent)
|
||||
|
||||
@@ -35,13 +35,13 @@ func (c *Commands) ChangeDefaultPasswordComplexityPolicy(ctx context.Context, po
|
||||
return nil, err
|
||||
}
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0oPew", "Errors.IAM.PasswordComplexityPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0oPew", "Errors.Instance.PasswordComplexityPolicy.NotFound")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingPolicy.PasswordComplexityPolicyWriteModel.WriteModel)
|
||||
changedEvent, hasChanged := existingPolicy.NewChangedEvent(ctx, instanceAgg, policy.MinLength, policy.HasLowercase, policy.HasUppercase, policy.HasNumber, policy.HasSymbol)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-9jlsf", "Errors.IAM.PasswordComplexityPolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-9jlsf", "Errors.Instance.PasswordComplexityPolicy.NotChanged")
|
||||
}
|
||||
pushedEvents, err := c.eventstore.Push(ctx, changedEvent)
|
||||
if err != nil {
|
||||
@@ -99,7 +99,7 @@ func (c *Commands) getDefaultPasswordComplexityPolicy(ctx context.Context) (*dom
|
||||
return nil, err
|
||||
}
|
||||
if !policyWriteModel.State.Exists() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-M0gsf", "Errors.IAM.PasswordComplexityPolicy.NotFound")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-M0gsf", "Errors.Instance.PasswordComplexityPolicy.NotFound")
|
||||
}
|
||||
policy := writeModelToPasswordComplexityPolicy(&policyWriteModel.PasswordComplexityPolicyWriteModel)
|
||||
policy.Default = true
|
||||
|
||||
@@ -37,7 +37,7 @@ func (c *Commands) ChangeDefaultLockoutPolicy(ctx context.Context, policy *domai
|
||||
return nil, err
|
||||
}
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0oPew", "Errors.IAM.LockoutPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0oPew", "Errors.Instance.LockoutPolicy.NotFound")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingPolicy.LockoutPolicyWriteModel.WriteModel)
|
||||
@@ -49,7 +49,7 @@ func (c *Commands) ChangeDefaultLockoutPolicy(ctx context.Context, policy *domai
|
||||
policy.ShowLockOutFailures,
|
||||
)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-0psjF", "Errors.IAM.LockoutPolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-0psjF", "Errors.Instance.LockoutPolicy.NotChanged")
|
||||
}
|
||||
|
||||
pushedEvents, err := c.eventstore.Push(ctx, changedEvent)
|
||||
|
||||
@@ -58,13 +58,13 @@ func (c *Commands) ChangeDefaultPrivacyPolicy(ctx context.Context, policy *domai
|
||||
return nil, err
|
||||
}
|
||||
if existingPolicy.State == domain.PolicyStateUnspecified || existingPolicy.State == domain.PolicyStateRemoved {
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0oPew", "Errors.IAM.PrivacyPolicy.NotFound")
|
||||
return nil, zerrors.ThrowNotFound(nil, "INSTANCE-0oPew", "Errors.Instance.PrivacyPolicy.NotFound")
|
||||
}
|
||||
|
||||
instanceAgg := InstanceAggregateFromWriteModel(&existingPolicy.PrivacyPolicyWriteModel.WriteModel)
|
||||
changedEvent, hasChanged := existingPolicy.NewChangedEvent(ctx, instanceAgg, policy.TOSLink, policy.PrivacyLink, policy.HelpLink, policy.SupportEmail, policy.DocsLink, policy.CustomLink, policy.CustomLinkText)
|
||||
if !hasChanged {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-9jJfs", "Errors.IAM.PrivacyPolicy.NotChanged")
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "INSTANCE-9jJfs", "Errors.Instance.PrivacyPolicy.NotChanged")
|
||||
}
|
||||
pushedEvents, err := c.eventstore.Push(ctx, changedEvent)
|
||||
if err != nil {
|
||||
@@ -96,7 +96,7 @@ func (c *Commands) getDefaultPrivacyPolicy(ctx context.Context) (*domain.Privacy
|
||||
return nil, err
|
||||
}
|
||||
if !policyWriteModel.State.Exists() {
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-559os", "Errors.IAM.PrivacyPolicy.NotFound")
|
||||
return nil, zerrors.ThrowInvalidArgument(nil, "INSTANCE-559os", "Errors.Instance.PrivacyPolicy.NotFound")
|
||||
}
|
||||
policy := writeModelToPrivacyPolicy(&policyWriteModel.PrivacyPolicyWriteModel)
|
||||
policy.Default = true
|
||||
|
||||
@@ -123,7 +123,7 @@ func (c *ChangeOrgMember) IsValid(zitadelRoles []authz.RoleMapping) error {
|
||||
return zerrors.ThrowInvalidArgument(nil, "Org-LiaZi", "Errors.Org.MemberInvalid")
|
||||
}
|
||||
if len(domain.CheckForInvalidRoles(c.Roles, domain.OrgRolePrefix, zitadelRoles)) > 0 {
|
||||
return zerrors.ThrowInvalidArgument(nil, "IAM-m9fG8", "Errors.Org.MemberInvalid")
|
||||
return zerrors.ThrowInvalidArgument(nil, "INST-m9fG8", "Errors.Org.MemberInvalid")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -143,7 +143,7 @@ func (c *Commands) AddLogoLabelPolicy(ctx context.Context, orgID string, upload
|
||||
}
|
||||
asset, err := c.uploadAsset(ctx, upload)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "IAM-4N3nf", "Errors.Assets.Object.PutFailed")
|
||||
return nil, zerrors.ThrowInternal(err, "INST-4N3nf", "Errors.Assets.Object.PutFailed")
|
||||
}
|
||||
orgAgg := OrgAggregateFromWriteModel(&existingPolicy.LabelPolicyWriteModel.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, org.NewLabelPolicyLogoAddedEvent(ctx, orgAgg, asset.Name))
|
||||
@@ -199,7 +199,7 @@ func (c *Commands) AddIconLabelPolicy(ctx context.Context, orgID string, upload
|
||||
}
|
||||
asset, err := c.uploadAsset(ctx, upload)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "IAM-4BS7f", "Errors.Assets.Object.PutFailed")
|
||||
return nil, zerrors.ThrowInternal(err, "INST-4BS7f", "Errors.Assets.Object.PutFailed")
|
||||
}
|
||||
orgAgg := OrgAggregateFromWriteModel(&existingPolicy.LabelPolicyWriteModel.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, org.NewLabelPolicyIconAddedEvent(ctx, orgAgg, asset.Name))
|
||||
@@ -256,7 +256,7 @@ func (c *Commands) AddLogoDarkLabelPolicy(ctx context.Context, orgID string, upl
|
||||
}
|
||||
asset, err := c.uploadAsset(ctx, upload)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "IAM-3S7fN", "Errors.Assets.Object.PutFailed")
|
||||
return nil, zerrors.ThrowInternal(err, "INST-3S7fN", "Errors.Assets.Object.PutFailed")
|
||||
}
|
||||
orgAgg := OrgAggregateFromWriteModel(&existingPolicy.LabelPolicyWriteModel.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, org.NewLabelPolicyLogoDarkAddedEvent(ctx, orgAgg, asset.Name))
|
||||
@@ -312,7 +312,7 @@ func (c *Commands) AddIconDarkLabelPolicy(ctx context.Context, orgID string, upl
|
||||
}
|
||||
asset, err := c.uploadAsset(ctx, upload)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "IAM-4B7cs", "Errors.Assets.Object.PutFailed")
|
||||
return nil, zerrors.ThrowInternal(err, "INST-4B7cs", "Errors.Assets.Object.PutFailed")
|
||||
}
|
||||
orgAgg := OrgAggregateFromWriteModel(&existingPolicy.LabelPolicyWriteModel.WriteModel)
|
||||
pushedEvents, err := c.eventstore.Push(ctx, org.NewLabelPolicyIconDarkAddedEvent(ctx, orgAgg, asset.Name))
|
||||
|
||||
Reference in New Issue
Block a user