https://github.com/gobuffalo/mw-basicauth
Buffalo Basic Auth Middleware
https://github.com/gobuffalo/mw-basicauth
authentication basic-authentication go gobuffalo golang middleware
Last synced: about 1 year ago
JSON representation
Buffalo Basic Auth Middleware
- Host: GitHub
- URL: https://github.com/gobuffalo/mw-basicauth
- Owner: gobuffalo
- License: mit
- Created: 2018-07-30T12:06:00.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2023-02-14T15:45:51.000Z (over 3 years ago)
- Last Synced: 2024-06-19T00:21:56.125Z (almost 2 years ago)
- Topics: authentication, basic-authentication, go, gobuffalo, golang, middleware
- Language: Go
- Size: 144 KB
- Stars: 6
- Watchers: 8
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# mw-basicauth
[](https://github.com/gobuffalo/mw-basicauth/actions/workflows/standard-go-test.yml)
[](https://pkg.go.dev/github.com/gobuffalo/mw-basicauth)
[](https://goreportcard.com/report/github.com/gobuffalo/mw-basicauth)
[Basic HTTP Authentication](https://tools.ietf.org/html/rfc7617) Middleware
for [Buffalo](https://github.com/gobuffalo/buffalo)
## Installation
```console
$ go get github.com/gobuffalo/mw-basicauth
```
## Usage
```go
auth := func(c buffalo.Context, u, p string) (bool, error) {
return (u == "username" && p == "password"), nil
}
app.Use(basicauth.Middleware(auth))
```
## Hitting protected endpoints
1. Base64 Encode `username:password`, which becomes `dXNlcm5hbWU6cGFzc3dvcmQK` in the aforementioned example
2. Then pass the following HTTP header along with all requests to protected endpoints: `Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQK`