mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 17:02:25 +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:
78
pkg/management/api/grpc/policy_complexity_converter.go
Normal file
78
pkg/management/api/grpc/policy_complexity_converter.go
Normal file
@@ -0,0 +1,78 @@
|
||||
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 passwordComplexityPolicyFromModel(policy *model.PasswordComplexityPolicy) *PasswordComplexityPolicy {
|
||||
creationDate, err := ptypes.TimestampProto(policy.CreationDate)
|
||||
logging.Log("GRPC-cQRHE").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
changeDate, err := ptypes.TimestampProto(policy.ChangeDate)
|
||||
logging.Log("GRPC-PVA1c").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
return &PasswordComplexityPolicy{
|
||||
Id: policy.AggregateID,
|
||||
CreationDate: creationDate,
|
||||
ChangeDate: changeDate,
|
||||
Description: policy.Description,
|
||||
Sequence: policy.Sequence,
|
||||
MinLength: policy.MinLength,
|
||||
HasLowercase: policy.HasLowercase,
|
||||
HasUppercase: policy.HasUppercase,
|
||||
HasNumber: policy.HasNumber,
|
||||
HasSymbol: policy.HasSymbol,
|
||||
IsDefault: policy.AggregateID == "",
|
||||
}
|
||||
}
|
||||
|
||||
func passwordComplexityPolicyToModel(policy *PasswordComplexityPolicy) *model.PasswordComplexityPolicy {
|
||||
creationDate, err := ptypes.Timestamp(policy.CreationDate)
|
||||
logging.Log("GRPC-asmEZ").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
changeDate, err := ptypes.Timestamp(policy.ChangeDate)
|
||||
logging.Log("GRPC-MCE4o").OnError(err).Debug("unable to parse timestamp")
|
||||
|
||||
return &model.PasswordComplexityPolicy{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: policy.Id,
|
||||
CreationDate: creationDate,
|
||||
ChangeDate: changeDate,
|
||||
Sequence: policy.Sequence,
|
||||
},
|
||||
Description: policy.Description,
|
||||
MinLength: policy.MinLength,
|
||||
HasLowercase: policy.HasLowercase,
|
||||
HasUppercase: policy.HasUppercase,
|
||||
HasNumber: policy.HasNumber,
|
||||
HasSymbol: policy.HasSymbol,
|
||||
}
|
||||
}
|
||||
|
||||
func passwordComplexityPolicyCreateToModel(policy *PasswordComplexityPolicyCreate) *model.PasswordComplexityPolicy {
|
||||
return &model.PasswordComplexityPolicy{
|
||||
Description: policy.Description,
|
||||
MinLength: policy.MinLength,
|
||||
HasLowercase: policy.HasLowercase,
|
||||
HasUppercase: policy.HasUppercase,
|
||||
HasNumber: policy.HasNumber,
|
||||
HasSymbol: policy.HasSymbol,
|
||||
}
|
||||
}
|
||||
|
||||
func passwordComplexityPolicyUpdateToModel(policy *PasswordComplexityPolicyUpdate) *model.PasswordComplexityPolicy {
|
||||
return &model.PasswordComplexityPolicy{
|
||||
ObjectRoot: models.ObjectRoot{
|
||||
AggregateID: policy.Id,
|
||||
},
|
||||
Description: policy.Description,
|
||||
MinLength: policy.MinLength,
|
||||
HasLowercase: policy.HasLowercase,
|
||||
HasUppercase: policy.HasUppercase,
|
||||
HasNumber: policy.HasNumber,
|
||||
HasSymbol: policy.HasSymbol,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user