zitadel/internal/api/grpc/admin/idp_config.go
Fabi dc56e298ae
fix: use domain models for v2 eventstore (#1151)
* fix: use domain models for v2 eventstore

* fix: user domain model

* Update internal/api/grpc/admin/login_policy_converter.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* fix: converter

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-01-05 09:33:45 +01:00

71 lines
2.1 KiB
Go

package admin
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"github.com/caos/zitadel/pkg/grpc/admin"
)
func (s *Server) IdpByID(ctx context.Context, id *admin.IdpID) (*admin.IdpView, error) {
config, err := s.query.DefaultIDPConfigByID(ctx, id.Id)
if err != nil {
return nil, err
}
return idpViewFromDomain(config), nil
}
func (s *Server) CreateOidcIdp(ctx context.Context, oidcIdpConfig *admin.OidcIdpConfigCreate) (*admin.Idp, error) {
config, err := s.command.AddDefaultIDPConfig(ctx, createOIDCIDPToDomain(oidcIdpConfig))
if err != nil {
return nil, err
}
return idpFromDomain(config), nil
}
func (s *Server) UpdateIdpConfig(ctx context.Context, idpConfig *admin.IdpUpdate) (*admin.Idp, error) {
config, err := s.command.ChangeDefaultIDPConfig(ctx, updateIdpToDomain(idpConfig))
if err != nil {
return nil, err
}
return idpFromDomain(config), nil
}
func (s *Server) DeactivateIdpConfig(ctx context.Context, id *admin.IdpID) (*admin.Idp, error) {
config, err := s.command.DeactivateDefaultIDPConfig(ctx, id.Id)
if err != nil {
return nil, err
}
return idpFromDomain(config), nil
}
func (s *Server) ReactivateIdpConfig(ctx context.Context, id *admin.IdpID) (*admin.Idp, error) {
config, err := s.command.ReactivateDefaultIDPConfig(ctx, id.Id)
if err != nil {
return nil, err
}
return idpFromDomain(config), nil
}
//TODO: Change To V2
func (s *Server) RemoveIdpConfig(ctx context.Context, id *admin.IdpID) (*empty.Empty, error) {
err := s.iam.RemoveIDPConfig(ctx, id.Id)
return &empty.Empty{}, err
}
func (s *Server) UpdateOidcIdpConfig(ctx context.Context, request *admin.OidcIdpConfigUpdate) (*admin.OidcIdpConfig, error) {
config, err := s.command.ChangeDefaultIDPOIDCConfig(ctx, updateOIDCIDPToDomain(request))
if err != nil {
return nil, err
}
return oidcIDPConfigFromDomain(config), nil
}
func (s *Server) SearchIdps(ctx context.Context, request *admin.IdpSearchRequest) (*admin.IdpSearchResponse, error) {
response, err := s.iam.SearchIDPConfigs(ctx, idpConfigSearchRequestToModel(request))
if err != nil {
return nil, err
}
return idpConfigSearchResponseFromModel(response), nil
}