monorepo for Hono third-party middleware/helpers/wrappers
 
 
Go to file
Kei Kamikawa 6c088c50ed
fixed to support service worker syntax
2022-07-29 23:03:09 +09:00
.github/workflows added good first issues labeler 2022-07-28 15:21:19 +09:00
src fixed to support service worker syntax 2022-07-29 23:03:09 +09:00
test fixed to support service worker syntax 2022-07-29 23:03:09 +09:00
.gitignore initial commit 2022-07-28 14:58:54 +09:00
README.md fixed documentation 2022-07-28 15:52:16 +09:00
firebase.json initial commit 2022-07-28 14:58:54 +09:00
jest.config.js removed unused params in jest.config.js 2022-07-28 15:19:21 +09:00
package.json fixed package.json urls 2022-07-29 22:45:13 +09:00
tsconfig.json Initial commit 2022-07-23 23:56:20 +09:00
yarn.lock initial commit 2022-07-28 14:58:54 +09:00

README.md

Hono Firebase Auth middleware for Cloudflare Workers.

This is a Firebase Auth middleware library for Hono which is used firebase-auth-cloudflare-workers.

Currently only Cloudflare Workers are supported officially. However, it may work in other environments as well, so please let us know in an issue if it works.

Synopsis

import { Hono } from "hono";
import { VerifyFirebaseAuthConfig, VerifyFirebaseAuthEnv, verifyFirebaseAuth, getFirebaseToken } from "@honojs/firebase-auth";

const config: VerifyFirebaseAuthConfig = {
  // specify your firebase project ID.
  projectId: "your-project-id",
}

// Or you can specify here the extended VerifyFirebaseAuthEnv type.
const app = new Hono<VerifyFirebaseAuthEnv>()

// set middleware
app.use("*", verifyFirebaseAuth(config));
app.get("/hello", (c) => {
  const idToken = getFirebaseToken(c) // get id-token object.
  return c.json(idToken)
});

export default app

Config (VerifyFirebaseAuthConfig)

projectId: string (required)

This field indicates your firebase project ID.

authorizationHeaderKey?: string (optional)

Based on this configuration, the JWT created by firebase auth is looked for in the HTTP headers. The default is "Authorization".

keyStore?: KeyStorer (optional)

This is used to cache the public key used to validate the Firebase ID token (JWT). This KeyStorer type has been defined in firebase-auth-cloudflare-workers library.

If you don't specify the field, this library uses WorkersKVStoreSingle instead. You must fill in the fields defined in VerifyFirebaseAuthEnv.

keyStoreInitializer?: (c: Context) => KeyStorer (optional)

Use this when initializing KeyStorer and environment variables, etc. are required.

If you don't specify the field, this library uses WorkersKVStoreSingle instead. You must fill in the fields defined in VerifyFirebaseAuthEnv.

disableErrorLog?: boolean (optional)

Throws an exception if JWT validation fails. By default, this is output to the error log, but if you don't expect it, use this.

Author

codehex https://github.com/Code-Hex

License

MIT