link-stack/packages/hapi-nextauth
2023-11-22 11:11:28 +01:00
..
src npm run fmt 2023-06-07 11:18:58 +00:00
.eslintrc.js Bring in hapi-nextauth and dev support libs 2023-03-13 08:24:20 +00:00
.gitignore Docker Compose refactoring 2023-06-21 12:48:07 +00:00
.npmignore Docker Compose refactoring 2023-06-21 12:48:07 +00:00
.prettierignore Bring in hapi-nextauth and dev support libs 2023-03-13 08:24:20 +00:00
babel.config.json Bring in hapi-nextauth and dev support libs 2023-03-13 08:24:20 +00:00
CHANGELOG.md Bring in hapi-nextauth and dev support libs 2023-03-13 08:24:20 +00:00
jest.config.json Bring in hapi-nextauth and dev support libs 2023-03-13 08:24:20 +00:00
LICENSE.md Bring in hapi-nextauth and dev support libs 2023-03-13 08:24:20 +00:00
package.json Fix email replies, update dependencies 2023-11-22 11:11:28 +01:00
README.md metamigo-api: runs in docker now 2023-06-02 15:26:30 +00:00
tsconfig.json npm run dev:metamigo now builds+watches all metamigo things!! 2023-06-07 08:24:13 +00:00

hapi-nextauth

This is a plugin for hapi.js that exposes NextAuth's database adapter via HTTP. Bring your own database.

Usage

import * as Hapi from "@hapi/hapi";
import Joi from "joi";
import NextAuthPlugin from "@digiresilience/hapi-nextauth";
import type { AdapterInstance } from "next-auth/adapters";


const server = new Hapi.Server();

// the validator must be registered before registering the plugin
await server.validator(Joi);

const nextAuthAdapterFactory: AdapterInstance = (request: Hapi.Request) => {
  ... instantiate your next auth adapter ...
}


// register the plugin
await server.register({
  plugin: NextAuthPlugin,
  options: {
    // the only required parameter is a function that returns your implementation of the NextAuthAdapter
    nextAuthAdapterFactory,
}});

Reference the next-auth typings for the adapter interface.

Options consist of:

  • nextAuthAdapterFactory - a function that returns your implementation of the NextAuthAdapter, it takes the Hapi Request as the sole argument.
  • basePath - a string that all next auth endpoints will be served from
  • sharedSecret - the secret used for basic authentication to the nextauth endpoints
  • validators - an object containing
    • profile - a Joi schema that validates a profile
    • user - a Joi schema that validates a user
    • userId - a Joi schema that validates a userId
    • session - a Joi schema that validates a session
  • tags - tags to add to the endpoints

Defaults are defined in src/index.ts

Credits

Copyright © 2020-present Center for Digital Resilience

Contributors

Abel Luck
Abel Luck

License

License: AGPL v3

GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.