mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 19:36:41 +00:00
feat: Policy (#79)
* 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>
This commit is contained in:
67
pkg/management/api/grpc/policy_lockout_converter.go
Normal file
67
pkg/management/api/grpc/policy_lockout_converter.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"github.com/caos/logging"
|
||||
"github.com/caos/zitadel/internal/eventstore/models"
|
||||
"github.com/caos/zitadel/internal/policy/model"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
)
|
||||
|
||||
func passwordLockoutPolicyFromModel(policy *model.PasswordLockoutPolicy) *PasswordLockoutPolicy {
|
||||
creationDate, err := ptypes.TimestampProto(policy.CreationDate)
|
||||
logging.Log("GRPC-JRSbT").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
changeDate, err := ptypes.TimestampProto(policy.ChangeDate)
|
||||
logging.Log("GRPC-1sizr").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
return &PasswordLockoutPolicy{
|
||||
Id: policy.AggregateID,
|
||||
CreationDate: creationDate,
|
||||
ChangeDate: changeDate,
|
||||
Sequence: policy.Sequence,
|
||||
Description: policy.Description,
|
||||
MaxAttempts: policy.MaxAttempts,
|
||||
ShowLockOutFailures: policy.ShowLockOutFailures,
|
||||
IsDefault: policy.AggregateID == "",
|
||||
}
|
||||
}
|
||||
|
||||
func passwordLockoutPolicyToModel(policy *PasswordLockoutPolicy) *model.PasswordLockoutPolicy {
|
||||
creationDate, err := ptypes.Timestamp(policy.CreationDate)
|
||||
logging.Log("GRPC-8a511").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
changeDate, err := ptypes.Timestamp(policy.ChangeDate)
|
||||
logging.Log("GRPC-2rdGv").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
return &model.PasswordLockoutPolicy{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: policy.Id,
|
||||
CreationDate: creationDate,
|
||||
ChangeDate: changeDate,
|
||||
Sequence: policy.Sequence,
|
||||
},
|
||||
Description: policy.Description,
|
||||
|
||||
MaxAttempts: policy.MaxAttempts,
|
||||
ShowLockOutFailures: policy.ShowLockOutFailures,
|
||||
}
|
||||
}
|
||||
|
||||
func passwordLockoutPolicyCreateToModel(policy *PasswordLockoutPolicyCreate) *model.PasswordLockoutPolicy {
|
||||
return &model.PasswordLockoutPolicy{
|
||||
Description: policy.Description,
|
||||
MaxAttempts: policy.MaxAttempts,
|
||||
ShowLockOutFailures: policy.ShowLockOutFailures,
|
||||
}
|
||||
}
|
||||
|
||||
func passwordLockoutPolicyUpdateToModel(policy *PasswordLockoutPolicyUpdate) *model.PasswordLockoutPolicy {
|
||||
return &model.PasswordLockoutPolicy{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: policy.Id,
|
||||
},
|
||||
Description: policy.Description,
|
||||
MaxAttempts: policy.MaxAttempts,
|
||||
ShowLockOutFailures: policy.ShowLockOutFailures,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user