package web import ( "net/http" "amadan.net/rastrillo/rastrillo/auth" ) // Where Base serves passkeys. The scripts are rastrillo's own: webauthn.mjs // runs the browser's half of a ceremony, and the door script reveals the // sign-in page's passkey button only where a ceremony can run. const ( webauthnModulePath = "/passkey/webauthn.mjs" passkeyDoorPath = "/passkey/signin.mjs" registerBeginPath = "/passkey/register/begin" registerFinishPath = "/passkey/register/finish" ) // passkeyDoor is the sign-in page's passkey button: the discover pair, which // signs a member in with a passkey alone. var passkeyDoor = auth.PasskeyDoor{ BeginPath: "/passkey/discover/begin", FinishPath: "/passkey/discover/finish", ModuleURL: webauthnModulePath, ScriptURL: passkeyDoorPath, } // serveScript answers with one JavaScript module. Its URL carries no // fingerprint, so the browser checks for a newer copy each time. func serveScript(body []byte) http.HandlerFunc { return func(w http.ResponseWriter, _ *http.Request) { w.Header().Set("Content-Type", "text/javascript; charset=utf-8") w.Header().Set("Cache-Control", "no-cache") _, _ = w.Write(body) } }