2022-02-25 16:05:06 +01:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
2022-09-27 11:53:49 +01:00
|
|
|
"google.golang.org/protobuf/types/known/durationpb"
|
|
|
|
|
2022-04-27 01:01:45 +02:00
|
|
|
obj_grpc "github.com/zitadel/zitadel/internal/api/grpc/object"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
|
|
admin_pb "github.com/zitadel/zitadel/pkg/grpc/admin"
|
|
|
|
settings_pb "github.com/zitadel/zitadel/pkg/grpc/settings"
|
2022-02-25 16:05:06 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func OIDCSettingsToPb(config *query.OIDCSettings) *settings_pb.OIDCSettings {
|
|
|
|
return &settings_pb.OIDCSettings{
|
|
|
|
Details: obj_grpc.ToViewDetailsPb(config.Sequence, config.CreationDate, config.ChangeDate, config.AggregateID),
|
|
|
|
AccessTokenLifetime: durationpb.New(config.AccessTokenLifetime),
|
|
|
|
IdTokenLifetime: durationpb.New(config.IdTokenLifetime),
|
|
|
|
RefreshTokenIdleExpiration: durationpb.New(config.RefreshTokenIdleExpiration),
|
|
|
|
RefreshTokenExpiration: durationpb.New(config.RefreshTokenExpiration),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-27 11:53:49 +01:00
|
|
|
func AddOIDCConfigToConfig(req *admin_pb.AddOIDCSettingsRequest) *domain.OIDCSettings {
|
|
|
|
return &domain.OIDCSettings{
|
|
|
|
AccessTokenLifetime: req.AccessTokenLifetime.AsDuration(),
|
|
|
|
IdTokenLifetime: req.IdTokenLifetime.AsDuration(),
|
|
|
|
RefreshTokenIdleExpiration: req.RefreshTokenIdleExpiration.AsDuration(),
|
|
|
|
RefreshTokenExpiration: req.RefreshTokenExpiration.AsDuration(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-25 16:05:06 +01:00
|
|
|
func UpdateOIDCConfigToConfig(req *admin_pb.UpdateOIDCSettingsRequest) *domain.OIDCSettings {
|
|
|
|
return &domain.OIDCSettings{
|
|
|
|
AccessTokenLifetime: req.AccessTokenLifetime.AsDuration(),
|
|
|
|
IdTokenLifetime: req.IdTokenLifetime.AsDuration(),
|
|
|
|
RefreshTokenIdleExpiration: req.RefreshTokenIdleExpiration.AsDuration(),
|
|
|
|
RefreshTokenExpiration: req.RefreshTokenExpiration.AsDuration(),
|
|
|
|
}
|
|
|
|
}
|