mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
3549a8b64e
* move mgmt pkg * begin package restructure * rename auth package to authz * begin start api * move auth * move admin * fix merge * configs and interceptors * interceptor * revert generate-grpc.sh * some cleanups * console * move console * fix tests and merging * js linting * merge * merging and configs * change k8s base to current ports * fixes * cleanup * regenerate proto * remove unnecessary whitespace * missing param * go mod tidy * fix merging * move login pkg * cleanup * move api pkgs again * fix pkg naming * fix generate-static.sh for login * update workflow * fixes * logging * remove duplicate * comment for optional gateway interfaces * regenerate protos * fix proto imports for grpc web * protos * grpc web generate * grpc web generate * fix changes * add translation interceptor * fix merging * regenerate mgmt proto
69 lines
2.2 KiB
Go
69 lines
2.2 KiB
Go
package management
|
|
|
|
import (
|
|
"github.com/caos/logging"
|
|
"github.com/golang/protobuf/ptypes"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
|
"github.com/caos/zitadel/internal/policy/model"
|
|
"github.com/caos/zitadel/pkg/grpc/management"
|
|
)
|
|
|
|
func passwordAgePolicyFromModel(policy *model.PasswordAgePolicy) *management.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 &management.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 *management.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 *management.PasswordAgePolicyCreate) *model.PasswordAgePolicy {
|
|
return &model.PasswordAgePolicy{
|
|
Description: policy.Description,
|
|
ExpireWarnDays: policy.ExpireWarnDays,
|
|
MaxAgeDays: policy.MaxAgeDays,
|
|
}
|
|
}
|
|
|
|
func passwordAgePolicyUpdateToModel(policy *management.PasswordAgePolicyUpdate) *model.PasswordAgePolicy {
|
|
return &model.PasswordAgePolicy{
|
|
ObjectRoot: models.ObjectRoot{
|
|
AggregateID: policy.Id,
|
|
},
|
|
Description: policy.Description,
|
|
ExpireWarnDays: policy.ExpireWarnDays,
|
|
MaxAgeDays: policy.MaxAgeDays,
|
|
}
|
|
}
|