...

Text file src/github.com/go-kit/kit/auth/basic/README.md

Documentation: github.com/go-kit/kit/auth/basic

     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)```.

View as plain text