Categorygithub.com/jpillora/cookieauth
modulepackage
1.1.1
Repository: https://github.com/jpillora/cookieauth.git
Documentation: pkg.go.dev

# README

cookieauth

Cookie-based Basic-Authentication HTTP middleware for Go (golang). Stores scrypt(user:pass) in a cookie. Prevents the need to keep entering basic-auth username and passwords over and over.

GoDoc CircleCI

Features

  • Simple
  • Thread-safe
  • Secured using scrypt

Usage

Get package:

$ go get -v github.com/jpillora/cookieauth

Quick use:

handler := http.HandlerFunc(...)
protected := cookieauth.Wrap(handler, "foo", "bar")
http.ListenAndServe(":3000", protected)

Customized use:

handler := http.HandlerFunc(...)

ca := cookieauth.New()
ca.SetID("session_token")
ca.SetUserPass("foo", "bar")
ca.SetExpiry(2 * time.Hour)
ca.SetLogger(log.New(os.Stdout, "", log.LstdFlags))

protected := ca.Wrap(handler)

http.ListenAndServe(":3000", protected)

Successful logins are hashed using scrypt and stored in a cookie.

MIT License

Copyright © 2016 Jaime Pillora <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Packages

No description provided by the author

# Functions

No description provided by the author
Wrap the provided handler with basic auth.
WrapWithRealm the provided handler with basic auth in the given realm.

# Structs

No description provided by the author