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

github.com/99designs/basicauth-go

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/99designs/basicauth-go

  • v0.0.0-20230316000542-bf6f9cbbf0f8
  • Source
  • Go
  • Socket score

Version published
Created
Source

basicauth-go

GoDoc Build Status

golang middleware for HTTP basic auth.

// Chi

router.Use(basicauth.New("MyRealm", map[string][]string{
    "bob": {"password1", "password2"},
}))


// Manual wrapping

middleware := basicauth.New("MyRealm", map[string][]string{
    "bob": {"password1", "password2"},
})

h := middlware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request)) {
    /// do stuff
})

log.Fatal(http.ListenAndServe(":8080", h))

env loading

If your environment looks like this:

SOME_PREFIX_BOB=password
SOME_PREFIX_JANE=password1,password2

you can load it like this:

middleware := basicauth.NewFromEnv("MyRealm", "SOME_PREFIX")

FAQs

Package last updated on 16 Mar 2023

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