summaryrefslogtreecommitdiff
path: root/website/manual.md
diff options
context:
space:
mode:
authorSimon Menke <simon.menke@gmail.com>2019-03-04 17:04:19 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-03-04 11:04:19 -0500
commit77d7ad61f39641b79a60a99da2f939cbc1d8fe39 (patch)
tree3bc46c49b0007fb83c435d6cf417dd0f844d947c /website/manual.md
parent048a8a77753881936d7c6b32f4534ee364eb42ad (diff)
Allow inspection and revocation of permissions (#1875)
Diffstat (limited to 'website/manual.md')
-rw-r--r--website/manual.md29
1 files changed, 29 insertions, 0 deletions
diff --git a/website/manual.md b/website/manual.md
index 9081637a1..43b79d003 100644
--- a/website/manual.md
+++ b/website/manual.md
@@ -286,6 +286,35 @@ It's worth noting that like the `cat.ts` example, the `copy()` function here
also does not make unnecessary memory copies. It receives a packet from the
kernel and sends back, without further complexity.
+### Inspecting and revoking permissions
+
+Sometimes a program may want to revoke previously granted permissions. When a
+program, at a later stage, needs those permissions, a new prompt will be
+presented to the user.
+
+```ts
+const { permissions, revokePermission, open, remove } = Deno;
+
+(async () => {
+ // lookup a permission
+ if (!permissions().write) {
+ throw new Error("need write permission");
+ }
+
+ const log = await open("request.log", "a+");
+
+ // revoke some permissions
+ revokePermission("read");
+ revokePermission("write");
+
+ // use the log file
+ await log.write(encoder.encode("hello\n"));
+
+ // this will prompt for the write permission or fail.
+ await remove("request.log");
+})();
+```
+
### File server
This one serves a local directory in HTTP.