2020-05-14 11:48:57 +02:00
|
|
|
package eventsourcing
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/caos/zitadel/internal/cache/config"
|
|
|
|
sd "github.com/caos/zitadel/internal/config/systemdefaults"
|
|
|
|
es_int "github.com/caos/zitadel/internal/eventstore"
|
2020-05-28 13:28:36 +02:00
|
|
|
"github.com/caos/zitadel/internal/id"
|
2020-05-14 11:48:57 +02:00
|
|
|
"github.com/caos/zitadel/internal/policy"
|
|
|
|
)
|
|
|
|
|
|
|
|
type PolicyEventstore struct {
|
|
|
|
es_int.Eventstore
|
|
|
|
policyCache *PolicyCache
|
2020-05-28 13:28:36 +02:00
|
|
|
idGenerator id.Generator
|
2020-05-14 11:48:57 +02:00
|
|
|
passwordAgePolicyDefault policy.PasswordAgePolicyDefault
|
|
|
|
passwordComplexityPolicyDefault policy.PasswordComplexityPolicyDefault
|
|
|
|
passwordLockoutPolicyDefault policy.PasswordLockoutPolicyDefault
|
|
|
|
}
|
|
|
|
|
|
|
|
type PolicyConfig struct {
|
|
|
|
es_int.Eventstore
|
|
|
|
Cache *config.CacheConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
func StartPolicy(conf PolicyConfig, systemDefaults sd.SystemDefaults) (*PolicyEventstore, error) {
|
|
|
|
policyCache, err := StartCache(conf.Cache)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &PolicyEventstore{
|
|
|
|
Eventstore: conf.Eventstore,
|
|
|
|
policyCache: policyCache,
|
2020-05-28 13:28:36 +02:00
|
|
|
idGenerator: id.SonyFlakeGenerator,
|
2020-05-14 11:48:57 +02:00
|
|
|
passwordAgePolicyDefault: systemDefaults.DefaultPolicies.Age,
|
|
|
|
passwordComplexityPolicyDefault: systemDefaults.DefaultPolicies.Complexity,
|
|
|
|
passwordLockoutPolicyDefault: systemDefaults.DefaultPolicies.Lockout,
|
|
|
|
}, nil
|
|
|
|
}
|