mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 15:02:13 +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:
66
pkg/management/api/grpc/policy_age_converter.go
Normal file
66
pkg/management/api/grpc/policy_age_converter.go
Normal file
@@ -0,0 +1,66 @@
|
||||
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 passwordAgePolicyFromModel(policy *model.PasswordAgePolicy) *PasswordAgePolicy {
|
||||
creationDate, err := ptypes.TimestampProto(policy.CreationDate)
|
||||
logging.Log("GRPC-6ILdB").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
changeDate, err := ptypes.TimestampProto(policy.ChangeDate)
|
||||
logging.Log("GRPC-ngUzJ").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
return &PasswordAgePolicy{
|
||||
Id: policy.AggregateID,
|
||||
CreationDate: creationDate,
|
||||
ChangeDate: changeDate,
|
||||
Sequence: policy.Sequence,
|
||||
Description: policy.Description,
|
||||
ExpireWarnDays: policy.ExpireWarnDays,
|
||||
MaxAgeDays: policy.MaxAgeDays,
|
||||
IsDefault: policy.AggregateID == "",
|
||||
}
|
||||
}
|
||||
|
||||
func passwordAgePolicyToModel(policy *PasswordAgePolicy) *model.PasswordAgePolicy {
|
||||
creationDate, err := ptypes.Timestamp(policy.CreationDate)
|
||||
logging.Log("GRPC-2QSfU").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
changeDate, err := ptypes.Timestamp(policy.ChangeDate)
|
||||
logging.Log("GRPC-LdU91").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
return &model.PasswordAgePolicy{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: policy.Id,
|
||||
CreationDate: creationDate,
|
||||
ChangeDate: changeDate,
|
||||
Sequence: policy.Sequence,
|
||||
},
|
||||
Description: policy.Description,
|
||||
ExpireWarnDays: policy.ExpireWarnDays,
|
||||
MaxAgeDays: policy.MaxAgeDays,
|
||||
}
|
||||
}
|
||||
|
||||
func passwordAgePolicyCreateToModel(policy *PasswordAgePolicyCreate) *model.PasswordAgePolicy {
|
||||
return &model.PasswordAgePolicy{
|
||||
Description: policy.Description,
|
||||
ExpireWarnDays: policy.ExpireWarnDays,
|
||||
MaxAgeDays: policy.MaxAgeDays,
|
||||
}
|
||||
}
|
||||
|
||||
func passwordAgePolicyUpdateToModel(policy *PasswordAgePolicyUpdate) *model.PasswordAgePolicy {
|
||||
return &model.PasswordAgePolicy{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: policy.Id,
|
||||
},
|
||||
Description: policy.Description,
|
||||
ExpireWarnDays: policy.ExpireWarnDays,
|
||||
MaxAgeDays: policy.MaxAgeDays,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user