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:
@@ -687,6 +687,61 @@ func TestBuilder_Build_SlackConnector(t *testing.T) {
|
||||
assert.Equal(t, "slack-signing-secret", rawSettings["signing-secret"])
|
||||
}
|
||||
|
||||
func TestBuilder_Build_CrispConnector(t *testing.T) {
|
||||
env := requiredEnv()
|
||||
env["PROBOD_CONNECTOR_CRISP_PLUGIN_TOKEN"] = "plugin-identifier:plugin-key"
|
||||
env["PROBOD_CONNECTOR_CRISP_PLUGIN_ID"] = "e979a1c3-2c41-4e93-a8ed-410ace27318e"
|
||||
|
||||
b := NewBuilder(NewResolver(mockEnv(env)))
|
||||
b.samlCertificate = "test-cert"
|
||||
b.samlPrivateKey = "test-key"
|
||||
|
||||
cfg, err := b.Build()
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, cfg.Probod.Connectors, 1)
|
||||
connector := cfg.Probod.Connectors[0]
|
||||
assert.Equal(t, "CRISP", connector.Provider)
|
||||
assert.Equal(t, "api_key", string(connector.Protocol))
|
||||
rawConfig := connector.RawConfig.(probodconfig.ConnectorConfigAPIKey)
|
||||
assert.Equal(t, "plugin-identifier:plugin-key", rawConfig.APIKey)
|
||||
assert.Equal(t, "e979a1c3-2c41-4e93-a8ed-410ace27318e", rawConfig.ResourceID)
|
||||
}
|
||||
|
||||
func TestBuilder_Build_CrispConnectorAbsentWithoutToken(t *testing.T) {
|
||||
// Without the plugin token the connector must not be configured, which
|
||||
// is what keeps Crisp deactivated until Crisp validates the plugin.
|
||||
b := NewBuilder(NewResolver(mockEnv(requiredEnv())))
|
||||
b.samlCertificate = "test-cert"
|
||||
b.samlPrivateKey = "test-key"
|
||||
|
||||
cfg, err := b.Build()
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, c := range cfg.Probod.Connectors {
|
||||
assert.NotEqual(t, "CRISP", c.Provider)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilder_Build_CrispConnectorAbsentWithoutPluginID(t *testing.T) {
|
||||
// The plugin token alone is not enough: the per-website plugin API needs
|
||||
// the plugin ID to verify website ownership, so a half-configured Crisp
|
||||
// connector stays hidden rather than activating in a broken state.
|
||||
env := requiredEnv()
|
||||
env["PROBOD_CONNECTOR_CRISP_PLUGIN_TOKEN"] = "plugin-identifier:plugin-key"
|
||||
|
||||
b := NewBuilder(NewResolver(mockEnv(env)))
|
||||
b.samlCertificate = "test-cert"
|
||||
b.samlPrivateKey = "test-key"
|
||||
|
||||
cfg, err := b.Build()
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, c := range cfg.Probod.Connectors {
|
||||
assert.NotEqual(t, "CRISP", c.Provider)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilder_Build_SAMLAutoGeneration(t *testing.T) {
|
||||
b := NewBuilder(NewResolver(mockEnv(requiredEnv())))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user