braid-text 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/server-demo.js +5 -13
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ Now open these URLs in your browser:
|
|
|
35
35
|
|
|
36
36
|
Or try opening the URL in [Braid-Chrome](https://github.com/braid-org/braid-chrome), or [another Braid client](https://bloop.monster/simpleditor), to edit it directly!
|
|
37
37
|
|
|
38
|
-
Check out the `server-demo.js` file to see examples for how to add access control, and a `/pages` endpoint to show all the edited pages.
|
|
38
|
+
Check out the `server-demo.js` file to see examples for how to add simple access control, where a user need only enter a password into a cookie in the javascript console like: `document.cookie = 'password'`; and a `/pages` endpoint to show all the edited pages.
|
|
39
39
|
|
|
40
40
|
## General Use on Server
|
|
41
41
|
|
package/package.json
CHANGED
package/server-demo.js
CHANGED
|
@@ -77,22 +77,14 @@ var server = require("http").createServer(async (req, res) => {
|
|
|
77
77
|
// return
|
|
78
78
|
// }
|
|
79
79
|
|
|
80
|
-
// TODO: uncomment
|
|
81
|
-
//
|
|
80
|
+
// TODO: uncomment out the code below to add basic access control,
|
|
81
|
+
// where a user logs in by openning the javascript console
|
|
82
|
+
// and entering: document.cookie = 'fake_password'
|
|
82
83
|
//
|
|
83
84
|
// var admin_pass = "fake_password"
|
|
84
|
-
//
|
|
85
|
-
// if (req.url === '/login_' + admin_pass) {
|
|
86
|
-
// res.writeHead(200, {
|
|
87
|
-
// "Content-Type": "text/plain",
|
|
88
|
-
// "Set-Cookie": `admin_pass=${admin_pass}; Path=/`,
|
|
89
|
-
// });
|
|
90
|
-
// res.end("Logged in successfully");
|
|
91
|
-
// return;
|
|
92
|
-
// }
|
|
93
|
-
//
|
|
85
|
+
//
|
|
94
86
|
// if (req.method == "PUT" || req.method == "POST" || req.method == "PATCH") {
|
|
95
|
-
// if (!req.headers.cookie?.
|
|
87
|
+
// if (!req.headers.cookie?.split(/;/).map(x => x.trim()).some(x => x === admin_pass)) {
|
|
96
88
|
// console.log("Blocked PUT:", { cookie: req.headers.cookie })
|
|
97
89
|
// res.statusCode = 401
|
|
98
90
|
// return res.end()
|