zitadel/internal/policy/repository/eventsourcing/eventstore.go
Fabi e3f9e9c05e
use global id generator (#142)
* use global id generator

* remove duplicate `UserRemoved`

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2020-05-28 13:28:36 +02:00

39 lines
1.3 KiB
Go

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"
"github.com/caos/zitadel/internal/id"
"github.com/caos/zitadel/internal/policy"
)
type PolicyEventstore struct {
es_int.Eventstore
policyCache *PolicyCache
idGenerator id.Generator
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,
idGenerator: id.SonyFlakeGenerator,
passwordAgePolicyDefault: systemDefaults.DefaultPolicies.Age,
passwordComplexityPolicyDefault: systemDefaults.DefaultPolicies.Complexity,
passwordLockoutPolicyDefault: systemDefaults.DefaultPolicies.Lockout,
}, nil
}