Skip to content

Commit b98fa3c

Browse files
committed
fix: start notifications with an empty deny-all provider list
1 parent da605c4 commit b98fa3c

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎encore-api/l3-core/notification/plugin_registry.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ func NewSafePluginClient(options PluginHTTPOptions) (*SafePluginClient, error) {
5555
if options.AllowHTTPTestOrigin && !options.TestMode {
5656
return nil, ErrPluginEndpoint
5757
}
58-
if !options.TestMode && len(options.AllowedOrigins) == 0 {
59-
return nil, ErrPluginEndpoint
60-
}
58+
// An unconfigured installation can manage notification groups without a
59+
// provider. pluginEndpoint still rejects every unlisted outbound origin.
6160
for _, origin := range options.AllowedOrigins {
6261
parsed, err := url.Parse(origin)
6362
if err != nil || !validPluginOriginShape(origin) {

‎encore-api/l3-core/notification/plugin_registry_test.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ import (
1515

1616
const safeManifestFixture = `{"api_version":"1.0","plugin_id":"fixture-mail","name":"Fixture Mail","plugin_version":"1.2.3","channels":["email"],"content_modes":["text"],"config_schema":{"type":"object","additionalProperties":false,"properties":{"region":{"type":"string","minLength":2},"password":{"type":"string","minLength":8}},"required":["region","password"]},"recipient_schema":{"type":"object","additionalProperties":false,"properties":{"kind":{"const":"email"},"address":{"type":"string","format":"email"}},"required":["kind","address"]},"secret_fields":["password"],"capabilities":{"delivery_receipts":true}}`
1717

18+
func TestUnconfiguredPluginClientDeniesOutboundOrigins(t *testing.T) {
19+
client, err := NewSafePluginClient(PluginHTTPOptions{})
20+
if err != nil {
21+
t.Fatalf("unconfigured notification provider prevented startup: %v", err)
22+
}
23+
for _, origin := range []string{"https://example.com", "https://frontend:8443", "http://127.0.0.1:8080"} {
24+
if _, _, err := client.FetchManifest(context.Background(), origin, "unused"); err != ErrPluginEndpoint {
25+
t.Fatalf("unlisted provider %q was not denied: %v", origin, err)
26+
}
27+
}
28+
}
29+
1830
func TestPluginEndpointRejectsUnsafeOrigins(t *testing.T) {
1931
for _, origin := range []string{
2032
"http://127.0.0.1:8080", "https://user:pass@example.com", "https://example.com/path", "https://example.com/", "https://example.com/?token=x", "https://example.com?", "https://example.com/#fragment", "https://example.com/#", "file:///etc/passwd",

0 commit comments

Comments
 (0)