Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

h3-basic-auth

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h3-basic-auth

> Basic Auth middleware for h3 / nitro / ... (based on [ezpass](https://github.com/unjs/ezpass))

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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 yarn install
  • Use yarn dev test/basic to start basic example

License

MIT

FAQs

Package last updated on 19 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc