• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..24-Jun-2019-

README.mdH A D24-Jun-2019882 2014

middleware.goH A D24-Jun-20192.5 KiB9571

middleware_test.goH A D24-Jun-20191.7 KiB5345

README.md

1This package provides a Basic Authentication middleware.
2
3It'll try to compare credentials from Authentication request header to a username/password pair in middleware constructor.
4
5More details about this type of authentication can be found in [Mozilla article](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication).
6
7## Usage
8
9```go
10import httptransport "github.com/go-kit/kit/transport/http"
11
12httptransport.NewServer(
13		AuthMiddleware(cfg.auth.user, cfg.auth.password, "Example Realm")(makeUppercaseEndpoint()),
14		decodeMappingsRequest,
15		httptransport.EncodeJSONResponse,
16		httptransport.ServerBefore(httptransport.PopulateRequestContext),
17	)
18```
19
20For AuthMiddleware to be able to pick up the Authentication header from an HTTP request we need to pass it through the context with something like ```httptransport.ServerBefore(httptransport.PopulateRequestContext)```.