Skip to content

Commit

Permalink
Device proxy: Check granular action access when possible
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
joshbwlng committed Feb 26, 2025
1 parent bc6687e commit cebd45a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/features/device-proxy/device-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,16 @@ async function requestDevices({
// Check for device update permission, except for
// internal operation of the platform.
if (method !== 'GET' && req !== permissions.root) {
const urlAction = url.split('/').pop() ?? '';
const action = ['purge', 'shutdown'].includes(urlAction)
? urlAction
: 'update';
await Promise.all(
deviceIds.map(async (deviceId) => {
const res = (await resinApi.request({
method: 'POST',
url: `device(${deviceId})/canAccess`,
body: { action: 'update' },
body: { action },
})) as { d?: Array<{ id: number }> };

if (res?.d?.[0]?.id !== deviceId) {
Expand Down

0 comments on commit cebd45a

Please sign in to comment.