mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 21:52:54 +00:00
# Which Problems Are Solved This PR implements the endpoints listed in https://github.com/zitadel/zitadel/issues/10444 . # How the Problems Are Solved The implementation follows the same pattern as the Instance one. The `Add` and `Remove` are implementing the `Commander` interface, while `List` Domains endpoints are implementing the `Querier` interace. The PR adds also some forgotten calls to the relational logic for the Instance API. The commits are identifiable by the label `instance:` prepended to them. This is the complete list: bafce01b0 , 6fe7257ab , e27bc9c34 , 8133ede73 , fde667953 , a3e1135ed , ee1a6f9c1 # Additional Context - Closes #10444 --------- Co-authored-by: Elio Bischof <[email protected]> Co-authored-by: Lebogang Phoshoko <[email protected]> Co-authored-by: Wim Van Laer <[email protected]> Co-authored-by: Max Peintner <[email protected]> Co-authored-by: Gayathri Vijayan <[email protected]>
80 lines
2.6 KiB
Go
80 lines
2.6 KiB
Go
package instance
|
|
|
|
import (
|
|
"context"
|
|
|
|
"connectrpc.com/connect"
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
instancev2 "github.com/zitadel/zitadel/backend/v3/api/instance/v2"
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
instance "github.com/zitadel/zitadel/pkg/grpc/instance/v2beta"
|
|
)
|
|
|
|
func (s *Server) AddCustomDomain(ctx context.Context, req *connect.Request[instance.AddCustomDomainRequest]) (*connect.Response[instance.AddCustomDomainResponse], error) {
|
|
if authz.GetFeatures(ctx).EnableRelationalTables {
|
|
return instancev2.AddCustomDomainBeta(ctx, req)
|
|
}
|
|
|
|
details, err := s.command.AddInstanceDomain(ctx, req.Msg.GetDomain())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return connect.NewResponse(&instance.AddCustomDomainResponse{
|
|
CreationDate: timestamppb.New(details.CreationDate),
|
|
}), nil
|
|
}
|
|
|
|
func (s *Server) RemoveCustomDomain(ctx context.Context, req *connect.Request[instance.RemoveCustomDomainRequest]) (*connect.Response[instance.RemoveCustomDomainResponse], error) {
|
|
if authz.GetFeatures(ctx).EnableRelationalTables {
|
|
return instancev2.RemoveCustomDomainBeta(ctx, req)
|
|
}
|
|
|
|
details, err := s.command.RemoveInstanceDomain(ctx, req.Msg.GetDomain(), false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var deletionDate *timestamppb.Timestamp
|
|
if details != nil {
|
|
deletionDate = timestamppb.New(details.EventDate)
|
|
}
|
|
|
|
return connect.NewResponse(&instance.RemoveCustomDomainResponse{
|
|
DeletionDate: deletionDate,
|
|
}), nil
|
|
}
|
|
|
|
func (s *Server) AddTrustedDomain(ctx context.Context, req *connect.Request[instance.AddTrustedDomainRequest]) (*connect.Response[instance.AddTrustedDomainResponse], error) {
|
|
if authz.GetFeatures(ctx).EnableRelationalTables {
|
|
return instancev2.AddTrustedDomainBeta(ctx, req)
|
|
}
|
|
|
|
details, err := s.command.AddTrustedDomain(ctx, req.Msg.GetDomain())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return connect.NewResponse(&instance.AddTrustedDomainResponse{
|
|
CreationDate: timestamppb.New(details.CreationDate),
|
|
}), nil
|
|
}
|
|
|
|
func (s *Server) RemoveTrustedDomain(ctx context.Context, req *connect.Request[instance.RemoveTrustedDomainRequest]) (*connect.Response[instance.RemoveTrustedDomainResponse], error) {
|
|
if authz.GetFeatures(ctx).EnableRelationalTables {
|
|
return instancev2.RemoveTrustedDomainBeta(ctx, req)
|
|
}
|
|
details, err := s.command.RemoveTrustedDomain(ctx, req.Msg.GetDomain(), false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var deletionDate *timestamppb.Timestamp
|
|
if details != nil {
|
|
deletionDate = timestamppb.New(details.EventDate)
|
|
}
|
|
|
|
return connect.NewResponse(&instance.RemoveTrustedDomainResponse{
|
|
DeletionDate: deletionDate,
|
|
}), nil
|
|
}
|