Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 17-Feb-2020 | - | ||||
README.md | H A D | 17-Feb-2020 | 882 | 20 | 14 | |
middleware.go | H A D | 17-Feb-2020 | 2.5 KiB | 95 | 71 | |
middleware_test.go | H A D | 17-Feb-2020 | 1.7 KiB | 53 | 45 |
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)```.