Crisp is a managed (Model B) connector: Probo holds one plugin token server-side and each connection carries only a Website ID. Nothing stops one organization from entering another organization's Website ID, so prove control of the website before creating the connection. Probo derives a per-(organization, website) verification code as an HMAC over the token secret and exposes it through a new crispVerificationCode query. The customer pastes it into the Probo plugin's per-website settings; at connect time the resolver reads the setting back through the managed plugin token and requires a constant-time match before any row is written. The managed key and plugin ID come from bootstrap, so the connector stays hidden until the deployment configures them. The settings fetch is injected so the create-time gate's branch wiring is unit-tested (mismatch and not-subscribed reject, internal errors stay generic, a matching code passes), and the managed-versus-client key resolution is covered too. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
90 lines
3.0 KiB
Go
90 lines
3.0 KiB
Go
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
|
//
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
// copyright notice and this permission notice appear in all copies.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
// PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
package console_v1
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"go.gearno.de/kit/log"
|
|
"go.probo.inc/probo/pkg/accessreview"
|
|
"go.probo.inc/probo/pkg/agentrun"
|
|
"go.probo.inc/probo/pkg/baseurl"
|
|
"go.probo.inc/probo/pkg/connector"
|
|
"go.probo.inc/probo/pkg/connector/provider"
|
|
"go.probo.inc/probo/pkg/cookiebanner"
|
|
"go.probo.inc/probo/pkg/esign"
|
|
"go.probo.inc/probo/pkg/filemanager"
|
|
"go.probo.inc/probo/pkg/iam"
|
|
"go.probo.inc/probo/pkg/mailman"
|
|
"go.probo.inc/probo/pkg/probo"
|
|
"go.probo.inc/probo/pkg/resourcealias"
|
|
"go.probo.inc/probo/pkg/riskmanagement"
|
|
"go.probo.inc/probo/pkg/server/api/authz"
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/dataloader"
|
|
"go.probo.inc/probo/pkg/server/api/console/v1/schema"
|
|
"go.probo.inc/probo/pkg/server/gqlutils"
|
|
"go.probo.inc/probo/pkg/thirdparty"
|
|
)
|
|
|
|
func NewGraphQLHandler(
|
|
iamSvc *iam.Service,
|
|
proboSvc *probo.Service,
|
|
resourceAliasSvc *resourcealias.Service,
|
|
esignSvc *esign.Service,
|
|
accessReviewSvc *accessreview.Service,
|
|
agentRunSvc *agentrun.Service,
|
|
mailmanSvc *mailman.Service,
|
|
cookieBannerSvc *cookiebanner.Service,
|
|
connectorRegistry *connector.ConnectorRegistry,
|
|
providerRegistry *provider.Registry,
|
|
customDomainCname string,
|
|
tokenSecret string,
|
|
logger *log.Logger,
|
|
thirdPartySvc *thirdparty.Service,
|
|
riskManagementSvc *riskmanagement.Service,
|
|
fileManagerSvc *filemanager.Service,
|
|
baseURL *baseurl.BaseURL,
|
|
limits gqlutils.Limits,
|
|
) http.Handler {
|
|
config := schema.Config{
|
|
Resolvers: &Resolver{
|
|
authorize: dataloader.NewAuthorizeFunc(logger),
|
|
batchAuthorize: authz.NewBatchAuthorizeFunc(iamSvc, logger),
|
|
probo: proboSvc,
|
|
resourceAlias: resourceAliasSvc,
|
|
iam: iamSvc,
|
|
esign: esignSvc,
|
|
accessReview: accessReviewSvc,
|
|
agentRun: agentRunSvc,
|
|
mailman: mailmanSvc,
|
|
cookieBanner: cookieBannerSvc,
|
|
connectorRegistry: connectorRegistry,
|
|
providerRegistry: providerRegistry,
|
|
riskManagement: riskManagementSvc,
|
|
thirdParty: thirdPartySvc,
|
|
customDomainCname: customDomainCname,
|
|
tokenSecret: tokenSecret,
|
|
fileManager: fileManagerSvc,
|
|
baseURL: baseURL,
|
|
logger: logger,
|
|
},
|
|
}
|
|
|
|
es := schema.NewExecutableSchema(config)
|
|
gqlh := gqlutils.NewHandler(es, logger, limits)
|
|
|
|
return gqlh
|
|
}
|