Enforce devbox allow lists without a Linux identity adapter
Wire the registrar allow-list callback before the OS-specific setup so Darwin refuses private links when visitor identity is unavailable. Keep SocketOwnerFor nil there because nil already refuses socket targets. Cover live and folder allow-list updates through the Darwin config seam.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+20
−5
devbox_cli.go+1 −1devbox_identity_linux_test.go+19 −4
CI failed — run details
diff --git a/devbox_cli.go b/devbox_cli.go| index a266df938..946b3697d 100644 |
| --- a/devbox_cli.go |
| +++ b/devbox_cli.go |
| @@ -675,6 +675,7 @@ func runDevboxServe(args []string) error { |
| } |
| func configureDevboxIdentity(goos string, r *devbox.Registrar, cfg *edge.DevboxConfig) error { |
| + cfg.AllowFor = r.AllowFor |
| if goos != "linux" { |
| return nil |
| } |
| @@ -696,7 +697,6 @@ func configureDevboxIdentity(goos string, r *devbox.Registrar, cfg *edge.DevboxC |
| cfg.SharedNodes = append(cfg.SharedNodes, node) |
| } |
| } |
| - cfg.AllowFor = r.AllowFor |
| cfg.SocketOwnerFor = r.SocketOwnerFor |
| return nil |
| } |
diff --git a/devbox_identity_linux_test.go b/devbox_identity_linux_test.go| index 799022207..e50ef3036 100644 |
| --- a/devbox_identity_linux_test.go |
| +++ b/devbox_identity_linux_test.go |
| @@ -80,17 +80,32 @@ func TestDevboxServeIdentityWiring(t *testing.T) { |
| } |
| func TestDevboxServeDarwinIdentityUnchanged(t *testing.T) { |
| - path := filepath.Join(t.TempDir(), "sockets") |
| + dir := t.TempDir() |
| + path := filepath.Join(dir, "sockets") |
| t.Setenv("CARLOS_DEVBOX_SOCKETS_DIR", path) |
| t.Setenv("CARLOS_DEVBOX_SHARED_NODES", "shared-one") |
| t.Setenv("CARLOS_DEVBOX_TAILSCALED_SOCKET", "/nonexistent") |
| - r := &devbox.Registrar{} |
| + links, err := devbox.OpenLinks(filepath.Join(dir, "links.json")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + r := &devbox.Registrar{Links: links, Domain: "devbox.example.com"} |
| cfg := edge.DevboxConfig{} |
| if err := configureDevboxIdentity("darwin", r, &cfg); err != nil { |
| t.Fatal(err) |
| } |
| - if r.SocketsDir != "" || cfg.Identity != nil || cfg.SharedNodes != nil || cfg.AllowFor != nil || cfg.SocketOwnerFor != nil { |
| - t.Fatalf("darwin identity enabled: %+v, %+v", r, cfg) |
| + if r.SocketsDir != "" || cfg.Identity != nil || cfg.SharedNodes != nil || cfg.AllowFor == nil || cfg.SocketOwnerFor != nil { |
| + t.Fatalf("darwin identity configuration: %+v, %+v", r, cfg) |
| + } |
| + for _, kind := range []devbox.Kind{devbox.KindLive, devbox.KindFolder} { |
| + for _, allow := range [][]string{{"alice@github"}, {"bob@github"}, nil} { |
| + if err := links.Put(devbox.Link{Name: "shop", Kind: kind, Allow: allow}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := cfg.AllowFor("shop.devbox.example.com"); !reflect.DeepEqual(got, allow) { |
| + t.Fatalf("darwin AllowFor for %s = %v, want %v", kind, got, allow) |
| + } |
| + } |
| } |
| if _, err := os.Lstat(path); !errors.Is(err, os.ErrNotExist) { |
| t.Fatalf("darwin sockets directory: %v", err) |