Verify Crisp website ownership before connecting
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>
This commit is contained in:
@@ -318,6 +318,26 @@ func (impl *Implm) Run(
|
||||
defaultConnectorRegistry := connector.NewConnectorRegistry()
|
||||
|
||||
for _, connectorCfg := range impl.cfg.Connectors {
|
||||
// ManagedAPIKey (Model B) connectors carry a Probo-held API key
|
||||
// instead of an OAuth2 client; register it on the provider registry
|
||||
// and skip the OAuth-only connector registry. Fail loudly on a
|
||||
// provider that is not a managed-api-key connector (e.g. a typo)
|
||||
// rather than silently swallowing the key, mirroring how the OAuth2
|
||||
// path surfaces misconfiguration at startup.
|
||||
if connectorCfg.Protocol == connector.ProtocolAPIKey {
|
||||
p := coredata.ConnectorProvider(connectorCfg.Provider)
|
||||
|
||||
reg, ok := providerRegistry.Get(p)
|
||||
if !ok || !reg.ManagedAPIKey {
|
||||
return fmt.Errorf("cannot configure api_key connector %q: not a managed-api-key provider", connectorCfg.Provider)
|
||||
}
|
||||
|
||||
providerRegistry.SetManagedAPIKey(p, connectorCfg.APIKey)
|
||||
providerRegistry.SetManagedResourceID(p, connectorCfg.ResourceID)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if oauth2c, ok := connectorCfg.Config.(*connector.OAuth2Connector); ok {
|
||||
if err := providerRegistry.ApplyOAuth2Defaults(connectorCfg.Provider, redirectURI, oauth2c); err != nil {
|
||||
return fmt.Errorf("cannot apply oauth2 defaults: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user