mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 12:27:59 +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>
67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
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,
|
|
}
|
|
}
|