Skip to content

Limit project link device ACLs to the device's own instance - #9083

Merged
Steve-Mcl merged 2 commits into
project-link-app-awarefrom
project-link-acl-tighten
Nov 3, 2026
Merged

Steve-Mcl merged 2 commits into
project-link-app-awarefrom
project-link-acl-tighten

Conversation

@Steve-Mcl

Copy link
Copy Markdown
Contributor

Description

Follow-up to #9079, stacked on its branch. It will retarget to main once #9079 merges.

Three device rules for project link checked only that the instance in the topic was in the device's team, not that it was the device's own instance. The devices are now limited to their own instance's topics:

  • subscribe to p/<instance>/in (direct messages)
  • subscribe to p/<instance>/res (link call responses)
  • publish to p/<instance>/out (team broadcasts)

All three now use checkDeviceAssignedToProject. The deviceOwnerType: 'instance' setting is gone from these rules. checkDeviceCanAccessProject never read it, so it had no effect, and application owned devices matched these rules as well.

GET /api/v1/teams/:teamId/projects now returns only id and name for device tokens, as it already does for project tokens. The only caller with a device token is nr-project-nodes, which only reads those two fields.

Sending stays open to the whole team. Any member can send a direct message to any instance or application owned device in the team, and reply to any link call, as before.

What each version of the nodes does

Topics drop the ff/v1/<team>/ prefix and the user's sub-topic. own is the client's id in topics: the instance id for a hosted instance, its instance's id for an instance owned device, dev:<deviceId> for an application owned device.

0.7.9, and 0.8.0 on a platform without /project-link/targets:

# Node action Topic Clients
1 In: broadcasts from all sub p/+/out All in same team
2 In: broadcasts from source S sub p/<S>/out All in same team. S is a hosted instance
3 In: direct messages sub p/<own>/in Hosted instances and instance owned devices. The node blocks it on application owned devices
4 Out: broadcast pub p/<own>/out All in same team
5 Out: direct to T pub p/<T>/in All in same team. T is a hosted instance in the same team
6 Call T pub p/<T>/in, sub p/<own>/res (res-<random> on HA) All in same team. T is a hosted instance in the same team
7 Out in return mode pub p/<caller>/res or res-<random> All in same team

Added in 0.8.0, on a platform with /project-link/targets:

# Node action Topic Clients
8 In: direct messages on an application owned device sub p/dev:<own>/in Application owned devices
9 Out direct, or Call, to an application owned device pub p/dev:<T>/in All in same team
10 Reply to an application owned device's call pub p/dev:<caller>/res All in same team
11 Reply to an HA instance's call from a device pub p/<instance>/res-<random> Devices in same team
12 In: broadcasts from one application owned device sub p/dev:<S>/out All in same team
13 Out: application broadcast pub a/<app>/p/<own>/out All in same application
14 In: application broadcasts sub a/<app>/p/+/out or a/<app>/p/<S>/out All in same application

Compatibility

Testing

  • Unit: 22 new cases in authRoutes_spec.js, and 1 changed. The application owned device can no longer subscribe to an instance inbox, so "can subscribe to project inbox" became "cannot subscribe to project inbox".
  • New cases cover:
    • an application owned device subscribing to its own response topic, which had no test
    • replies to dev: callers, and broadcasts from dev: sources
    • wildcard subscriptions to p/+/in and p/+/res
    • broadcasting as another client
    • other team topics, using a real second team and instance
  • team_spec.js checks device tokens get only id and name.

Related Issue(s)

Closes FlowFuse/engineering#592
Part of FlowFuse/nr-project-nodes#30

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on FlowFuse/helm to update ConfigMap Template
    • Issue/PR raised on FlowFuse/CloudProject to update values for Staging/Production
  • Link to Changelog Entry PR, or note why one is not needed. Not needed: no change for any released version of the nodes

Labels

  • Includes a DB migration? -> add the area:migration label

@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.88%. Comparing base (99c4656) to head (967ae9e).

Additional details and impacted files
@@                   Coverage Diff                   @@
##           project-link-app-aware    #9083   +/-   ##
=======================================================
  Coverage                   79.88%   79.88%           
=======================================================
  Files                         476      476           
  Lines                       26164    26164           
  Branches                     6972     6972           
=======================================================
  Hits                        20902    20902           
  Misses                       5262     5262           
Flag Coverage Δ
backend 79.88% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Steve-Mcl
Steve-Mcl requested a review from andypalmi October 30, 2026 17:06
@Steve-Mcl
Steve-Mcl marked this pull request as ready for review October 30, 2026 17:08
@Steve-Mcl
Steve-Mcl added this pull request to stack #9085 October 30, 2026 17:08
@Steve-Mcl
Steve-Mcl force-pushed the project-link-acl-tighten branch from 38ad95b to 56548dd Compare October 30, 2026 17:11

@andypalmi andypalmi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran the same 56 ACL cases against /api/comms/v2/acls on this branch: all 56 pass, including the 6 team channel cases that fail on #9079 alone. Runtime traffic between hosted instances, application owned, instance owned and device group devices is unchanged. Approving.

@Steve-Mcl

Copy link
Copy Markdown
Contributor Author

This has been rechecked by myself and @andypalmi but I am holding off merge until tomorrow morning when i around in case of issue.

@Steve-Mcl

Steve-Mcl commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

final testing on pre-staging with real devices and existing 0.7.9 version link nodes:

Setup

  • Team "Plant Enterprise"
    • App "Acme Plant"
      • Instance "Plant-Live-02"
      • Device "plant-ent-device"
    • App "Other App"
      • Instance "other-app-instance"
        • instance owned device "other-app-device
image image image image

Flows used

other-app-instance.json
plant-live-02.json
plant-ent-device.json

- Device subscriptions to p/<instance>/in and p/<instance>/res, and device
  publishes to p/<instance>/out, now use checkDeviceAssignedToProject so a
  device only uses its own instance's topics
- Return only id and name from GET /teams/:teamId/projects for device tokens,
  as already done for project tokens
- Add ACL tests for wildcard, cross-team and dev: response/broadcast topics
@Steve-Mcl
Steve-Mcl force-pushed the project-link-acl-tighten branch from 56548dd to 967ae9e Compare November 3, 2026 10:47
@Steve-Mcl
Steve-Mcl enabled stacked auto-merge (squash) November 3, 2026 10:47
@Steve-Mcl
Steve-Mcl merged commit e12e795 into main Nov 3, 2026
31 checks passed
@Steve-Mcl
Steve-Mcl deleted the project-link-acl-tighten branch November 3, 2026 10:55
@Steve-Mcl

Steve-Mcl commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

final testing on pre-staging with real devices and existing 0.7.9 version link nodes:

Setup

  • Team "Plant Enterprise"

    • App "Acme Plant"

      • Instance "Plant-Live-02"
      • Device "plant-ent-device"
    • App "Other App"

      • Instance "other-app-instance"

        • instance owned device "other-app-device

This setup was recreated on our staging env in team "Plant Enterprise"

  • Tested against 0.7.9 nodes - working as expected - 👍
  • Updated to nightly version 0.7.10-83493b4-202611021839.0 (which includes application aware logic) and re-tested - 👍

This branch was previously deployed

1 inactive deployment
staging — 967ae9e7 Deployed Nov 3, 2026 by Steve-Mcl via Remove application #12861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants