An open API service indexing awesome lists of open source software.

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

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