Giter Club home page Giter Club logo

h3-basic-auth's Introduction

h3-basic-auth

Basic Auth middleware for h3 / nitro / ... (based on ezpass)

Usage

With h3

import { createApp, defineEventHandler, toNodeListener } from 'h3'
import { listen } from 'listhen'
import { createBasicAuthMiddleware } from 'h3-basic-auth'

const app = createApp()

app.use(createBasicAuthMiddleware({
  sessionSecret: 'secret', // Set this to something useful
  username: 'test', // The valid username
  password: 'test' // The valid password
}))

app.use(defineEventHandler(event => `Welcome ${event.context.auth?.session.user}!`))

listen(toNodeListener(app))

With Nitro

// server/middleware/basic-auth.ts
export default createBasicAuthMiddleware({
  sessionSecret: 'secret', // Set this to something useful
  username: 'test', // The valid username
  password: 'test' // The valid password
})

Options

  • sessionSecret
  • bypass
  • onAuthorize
  • username
  • password
app.use(createBasicAuthMiddleware({
  provider: 'basic',
  username: 'test',
  password: 'test'
}))

Development

  • Clone Repository
  • Install dependencies with pnpm install
  • Use pnpm dev test/basic to start basic example

License

MIT

h3-basic-auth's People

Contributors

mannil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

h3-basic-auth's Issues

Automate tests

Right now, the tests are "manually to do". It'd be great to update the tests, ensuring that they can run in a CI ☺️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.