2020-08-26 09:56:23 +02:00
|
|
|
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) {
|
2021-01-05 09:33:45 +01:00
|
|
|
config, err := s.query.DefaultIDPConfigByID(ctx, id.Id)
|
2020-08-26 09:56:23 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-05 09:33:45 +01:00
|
|
|
return idpViewFromDomain(config), nil
|
2020-08-26 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) CreateOidcIdp(ctx context.Context, oidcIdpConfig *admin.OidcIdpConfigCreate) (*admin.Idp, error) {
|
2021-01-05 09:33:45 +01:00
|
|
|
config, err := s.command.AddDefaultIDPConfig(ctx, createOIDCIDPToDomain(oidcIdpConfig))
|
2020-08-26 09:56:23 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-05 09:33:45 +01:00
|
|
|
return idpFromDomain(config), nil
|
2020-08-26 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) UpdateIdpConfig(ctx context.Context, idpConfig *admin.IdpUpdate) (*admin.Idp, error) {
|
2021-01-05 09:33:45 +01:00
|
|
|
config, err := s.command.ChangeDefaultIDPConfig(ctx, updateIdpToDomain(idpConfig))
|
2020-08-26 09:56:23 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-05 09:33:45 +01:00
|
|
|
return idpFromDomain(config), nil
|
2020-08-26 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) DeactivateIdpConfig(ctx context.Context, id *admin.IdpID) (*admin.Idp, error) {
|
2021-01-05 09:33:45 +01:00
|
|
|
config, err := s.command.DeactivateDefaultIDPConfig(ctx, id.Id)
|
2020-08-26 09:56:23 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-05 09:33:45 +01:00
|
|
|
return idpFromDomain(config), nil
|
2020-08-26 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) ReactivateIdpConfig(ctx context.Context, id *admin.IdpID) (*admin.Idp, error) {
|
2021-01-05 09:33:45 +01:00
|
|
|
config, err := s.command.ReactivateDefaultIDPConfig(ctx, id.Id)
|
2020-08-26 09:56:23 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-05 09:33:45 +01:00
|
|
|
return idpFromDomain(config), nil
|
2020-08-26 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RemoveIdpConfig(ctx context.Context, id *admin.IdpID) (*empty.Empty, error) {
|
2021-01-18 11:24:15 +01:00
|
|
|
err := s.command.RemoveDefaultIDPConfig(ctx, id.Id)
|
2020-08-26 09:56:23 +02:00
|
|
|
return &empty.Empty{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) UpdateOidcIdpConfig(ctx context.Context, request *admin.OidcIdpConfigUpdate) (*admin.OidcIdpConfig, error) {
|
2021-01-05 09:33:45 +01:00
|
|
|
config, err := s.command.ChangeDefaultIDPOIDCConfig(ctx, updateOIDCIDPToDomain(request))
|
2020-08-26 09:56:23 +02:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-05 09:33:45 +01:00
|
|
|
return oidcIDPConfigFromDomain(config), nil
|
2020-08-26 09:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|