Password Authentication

Protect your vals behind a password

pomdtr/password_auth_example
import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth";
This is the server I want to protect.
pomdtr/password_auth_example
const server = () => {
  return new Response("You're authenticated!");
};
Your password should be stored in an env var. For this example, the password is val_town_is_awesome.
pomdtr/password_auth_example
const password = Deno.env.get("EXAMPLE_PASSWORD");
We can add authentication by simply wrapping the server in the passwordAuth middleware. If you don't set the password option, you can still use a val.town token to authenticate.
pomdtr/password_auth_example
export default passwordAuth(server, { password: password });

Additional resources: