Deno: Request and Revoke Permissions doesn't work properly

Created on 14 Aug 2020  路  1Comment  路  Source: denoland/deno

Problem with Deno and permissions.
When read access is requested for a specific folder, each read access request is either granted or denied, depending on what the user decides on the first request.

deno run --unstable app.ts

// --> Deno requests read access to "./file1" --> grant
const status1 = await Deno.permissions.request({ name: "read", path: "./file1" });  
const status2 = await Deno.permissions.request({ name: "read", path: "./file2" });  // --> Deno skip request
console.log("Request ./file1", status1.state);    // --> Granted     | Denied 
console.log("Request ./file2", status2.state);    // --> Granted [!] | Denied [!]

Same for revoke permissions
deno run --unstable --allow-read=./file1,./file2 app.ts
case 1:

// --> Deno revoke read access to "./file1"
const status1 = await Deno.permissions.revoke({ name: "read", path: "./file1" }); 
const status2 = await Deno.permissions.query({ name: "read", path: "./file1" });
const status3 = await Deno.permissions.query({ name: "read", path: "./file2" });
console.log("Request ./file1", status1.state);    // --> Granted [!]
console.log("Request ./file1", status2.state);    // --> Granted [!]
console.log("Request ./file2", status2.state);    // --> Granted

case 2:

const status1 = await Deno.permissions.revoke({ name: "read" });  // --> Deno revoke read access
const status2 = await Deno.permissions.query({ name: "read", path: "./file1" });
const status3 = await Deno.permissions.query({ name: "read", path: "./file2" });
console.log("Request ./file1", status1.state);    // --> Prompt
console.log("Request ./file1", status2.state);    // --> Granted [!]
console.log("Request ./file2", status2.state);    // --> Granted [!]
bug cli permissions

Most helpful comment

They way we model permission state is totally insufficient. I'm doing a big refactor of cli/permissions.rs and its consumers. Requests and revokes will be modelled properly with separate allowlists and denylists.

>All comments

They way we model permission state is totally insufficient. I'm doing a big refactor of cli/permissions.rs and its consumers. Requests and revokes will be modelled properly with separate allowlists and denylists.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

somombo picture somombo  路  3Comments

CruxCv picture CruxCv  路  3Comments

zugende picture zugende  路  3Comments

doutchnugget picture doutchnugget  路  3Comments

ry picture ry  路  3Comments