mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
b9c938594c
* policy added * Make it executable * Make it executable, corrections * password age policy added * password lockout policy added * corrections * policy added * Make it executable * Make it executable, corrections * password age policy added * password lockout policy added * corrections * fix(repository): remove second policy * complaints corrected * Init tests * add some tests * more tests added * systemfefaults added * default values load added * check for default value added * fixes * fixed * create policy if not exists * eventstore tests added Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
package eventsourcing
|
|
|
|
import (
|
|
"github.com/caos/logging"
|
|
"github.com/caos/zitadel/internal/cache"
|
|
"github.com/caos/zitadel/internal/cache/config"
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
|
)
|
|
|
|
type PolicyCache struct {
|
|
policyCache cache.Cache
|
|
}
|
|
|
|
func StartCache(conf *config.CacheConfig) (*PolicyCache, error) {
|
|
policyCache, err := conf.Config.NewCache()
|
|
logging.Log("EVENT-vDneN").OnError(err).Panic("unable to create policy cache")
|
|
|
|
return &PolicyCache{policyCache: policyCache}, nil
|
|
}
|
|
|
|
func (c *PolicyCache) getPolicy(id string) (policy *PasswordComplexityPolicy) {
|
|
policy = &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: id}}
|
|
if err := c.policyCache.Get(id, policy); err != nil {
|
|
logging.Log("EVENT-4eTZh").WithError(err).Debug("error in getting cache")
|
|
}
|
|
return policy
|
|
}
|
|
|
|
func (c *PolicyCache) cachePolicy(policy *PasswordComplexityPolicy) {
|
|
err := c.policyCache.Set(policy.AggregateID, policy)
|
|
if err != nil {
|
|
logging.Log("EVENT-ThnBb").WithError(err).Debug("error in setting policy cache")
|
|
}
|
|
}
|