Files
probo/pkg/server/api/console/v1/connector_resolvers.go
Sacha Al Himdani 88242eed87 Restore MCP cross-origin protection after go-sdk v1.6.0 bump
The go-sdk v1.6.0 release no longer applies a default
CrossOriginProtection when the field is nil in StreamableHTTPOptions,
silently removing Origin header verification. Wrap the streamable
handler with http.NewCrossOriginProtection().Handler(...) (the
recommended replacement, since the SDK field is deprecated).

Also regenerate gqlgen resolvers to track v0.17.90.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
2026-05-05 14:46:04 +02:00

183 lines
6.1 KiB
Go

package console_v1
// This file will be automatically regenerated based on the schema, any resolver
// implementations
// will be copied through when generating and any unknown code will be moved to the end.
// Code generated by github.com/99designs/gqlgen version v0.17.90
import (
"context"
"errors"
"fmt"
"go.gearno.de/kit/log"
"go.probo.inc/probo/pkg/accessreview/drivers"
"go.probo.inc/probo/pkg/connector"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/probo"
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
"go.probo.inc/probo/pkg/server/api/console/v1/types"
"go.probo.inc/probo/pkg/server/gqlutils"
)
// Oauth2Scopes is the resolver for the oauth2Scopes field.
func (r *connectorResolver) Oauth2Scopes(ctx context.Context, obj *types.Connector) ([]string, error) {
scopes := drivers.ProviderOAuth2Scopes(obj.Provider)
if scopes == nil {
return []string{}, nil
}
return scopes, nil
}
// CreateAPIKeyConnector is the resolver for the createAPIKeyConnector field.
func (r *mutationResolver) CreateAPIKeyConnector(ctx context.Context, input types.CreateAPIKeyConnectorInput) (*types.CreateAPIKeyConnectorPayload, error) {
if err := r.authorize(ctx, input.OrganizationID, probo.ActionConnectorCreate); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
req := probo.CreateConnectorRequest{
OrganizationID: input.OrganizationID,
Provider: input.Provider,
Protocol: coredata.ConnectorProtocolAPIKey,
Connection: &connector.APIKeyConnection{APIKey: input.APIKey},
}
if input.TallyOrganizationID != nil {
req.TallySettings = &coredata.TallyConnectorSettings{
OrganizationID: *input.TallyOrganizationID,
}
}
if input.SentryOrganizationSlug != nil {
req.SentrySettings = &coredata.SentryConnectorSettings{
OrganizationSlug: *input.SentryOrganizationSlug,
}
}
if input.SupabaseOrganizationSlug != nil {
req.SupabaseSettings = &coredata.SupabaseConnectorSettings{
OrganizationSlug: *input.SupabaseOrganizationSlug,
}
}
if input.GithubOrganization != nil {
req.GitHubSettings = &coredata.GitHubConnectorSettings{
Organization: *input.GithubOrganization,
}
}
if input.OnePasswordScimBridgeURL != nil {
req.OnePasswordSettings = &coredata.OnePasswordConnectorSettings{
SCIMBridgeURL: *input.OnePasswordScimBridgeURL,
}
}
cnnctr, err := prb.Connectors.Create(ctx, req)
if err != nil {
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
return nil, gqlutils.Conflict(ctx, err)
}
panic(fmt.Errorf("cannot create API key connector: %w", err))
}
return &types.CreateAPIKeyConnectorPayload{
Connector: types.NewConnector(cnnctr),
}, nil
}
// CreateClientCredentialsConnector is the resolver for the createClientCredentialsConnector field.
func (r *mutationResolver) CreateClientCredentialsConnector(ctx context.Context, input types.CreateClientCredentialsConnectorInput) (*types.CreateClientCredentialsConnectorPayload, error) {
if err := r.authorize(ctx, input.OrganizationID, probo.ActionConnectorCreate); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.OrganizationID.TenantID())
oauth2Conn := &connector.OAuth2Connection{
GrantType: connector.OAuth2GrantTypeClientCredentials,
ClientID: input.ClientID,
ClientSecret: input.ClientSecret,
TokenURL: input.TokenURL,
}
if input.Scope != nil {
oauth2Conn.Scope = *input.Scope
}
req := probo.CreateConnectorRequest{
OrganizationID: input.OrganizationID,
Provider: input.Provider,
Protocol: coredata.ConnectorProtocolOAuth2,
Connection: oauth2Conn,
}
if input.OnePasswordAccountID != nil && input.OnePasswordRegion != nil {
req.OnePasswordUsersAPISettings = &coredata.OnePasswordUsersAPISettings{
AccountID: *input.OnePasswordAccountID,
Region: *input.OnePasswordRegion,
}
}
cnnctr, err := prb.Connectors.Create(ctx, req)
if err != nil {
if errors.Is(err, coredata.ErrResourceAlreadyExists) {
return nil, gqlutils.Conflict(ctx, err)
}
panic(fmt.Errorf("cannot create client credentials connector: %w", err))
}
return &types.CreateClientCredentialsConnectorPayload{
Connector: types.NewConnector(cnnctr),
}, nil
}
// DeleteConnector is the resolver for the deleteConnector field.
func (r *mutationResolver) DeleteConnector(ctx context.Context, input types.DeleteConnectorInput) (*types.DeleteConnectorPayload, error) {
if err := r.authorize(ctx, input.ConnectorID, probo.ActionConnectorDelete); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.ConnectorID.TenantID())
if err := prb.Connectors.Delete(ctx, input.ConnectorID); err != nil {
panic(fmt.Errorf("cannot delete connector: %w", err))
}
return &types.DeleteConnectorPayload{
DeletedConnectorID: input.ConnectorID,
}, nil
}
// DeleteSlackConnection is the resolver for the deleteSlackConnection field.
func (r *mutationResolver) DeleteSlackConnection(ctx context.Context, input types.DeleteSlackConnectionInput) (*types.DeleteSlackConnectionPayload, error) {
if err := r.authorize(ctx, input.SlackConnectionID, probo.ActionConnectorDelete); err != nil {
return nil, err
}
prb := r.ProboService(ctx, input.SlackConnectionID.TenantID())
err := prb.Connectors.Delete(ctx, input.SlackConnectionID)
if err != nil {
r.logger.ErrorCtx(ctx, "cannot delete slack connection", log.Error(err))
return nil, gqlutils.Internal(ctx)
}
return &types.DeleteSlackConnectionPayload{
DeletedSlackConnectionID: input.SlackConnectionID,
}, nil
}
// Permission is the resolver for the permission field.
func (r *slackConnectionResolver) Permission(ctx context.Context, obj *types.SlackConnection, action string) (bool, error) {
return r.Resolver.Permission(ctx, obj, action)
}
// Connector returns schema.ConnectorResolver implementation.
func (r *Resolver) Connector() schema.ConnectorResolver { return &connectorResolver{r} }
// SlackConnection returns schema.SlackConnectionResolver implementation.
func (r *Resolver) SlackConnection() schema.SlackConnectionResolver {
return &slackConnectionResolver{r}
}
type connectorResolver struct{ *Resolver }
type slackConnectionResolver struct{ *Resolver }