https://github.com/kt3k/basic_auth
Module for performing Basic Auth in Deno Deploy
https://github.com/kt3k/basic_auth
deno deno-deploy
Last synced: 8 months ago
JSON representation
Module for performing Basic Auth in Deno Deploy
- Host: GitHub
- URL: https://github.com/kt3k/basic_auth
- Owner: kt3k
- Created: 2021-05-28T07:00:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-30T05:26:45.000Z (over 3 years ago)
- Last Synced: 2025-05-09T01:17:22.174Z (8 months ago)
- Topics: deno, deno-deploy
- Language: TypeScript
- Homepage: https://deno.land/x/basic_auth
- Size: 15.6 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# basic_auth v1.1.1
Module for performing Basic Auth in Deno Deploy.
[Demo](https://basic-auth-demo.deno.dev/)
# Usage
import `basicAuth` function from the module url and use it like the below:
```ts
import { basicAuth } from "https://deno.land/x/basic_auth@v1.1.1/mod.ts";
addEventListener("fetch", (e) => {
const unauthorized = basicAuth(e.request, "Access to my site", {
"user": "password",
});
if (unauthorized) {
e.respondWith(unauthorized);
return;
}
e.respondWith(new Response("You are authorized!"));
});
```
Replace `user` and `password` part with your credentials. You can also set
multiple credentials by setting multiple key value pairs in the 3rd parameter.
# [API doc](https://doc.deno.land/https/deno.land/x/basic_auth/mod.ts)
# LICENSE
MIT