From a7f7520a23a140f737698fe725b0bd6e0a590f5c Mon Sep 17 00:00:00 2001 From: yizhibian <1119155090@qq.com> Date: Tue, 25 Jul 2023 23:25:49 +0800 Subject: [PATCH] docs: update README.md --- README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d9b392..9ac9ee1 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,56 @@ # envoy-go-basic-auth -Basic Auth based on Envoy Golang http filter + +This is a simple basic auth filter for envoy written in go. Only requests that pass the configuration authentication will be proxied to the upstream service. + +## Status + +This is under active development and is not ready for production use. + +## Usage + +The client set credentials in `Authorization` header in the following format: + +```Plaintext +credentials := Basic base64(username:password) +``` + +An example of the `Authorization` header is as follows (`Zm9vOmJhcg==`, which is the base64-encoded value of `foo:bar`): + +```Plaintext +Authorization: Basic Zm9vOmJhcg== +``` + +Configure your envoy.yaml to set pairs of username and password. + +```yaml +http_filters: +- name: envoy.filters.http.golang +typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.golang.v3alpha.Config + library_id: example + library_path: /etc/envoy/libgolang.so + plugin_name: basic-auth + plugin_config: + "@type": type.googleapis.com/xds.type.v3.TypedStruct + value: + users: + - username: "foo" + password: "bar" + - username: "lobby" + password: "niu" +``` + +Then, you can start your filter. + +```bash +make build +make run +``` + +## Test + +This test case is based on a local Envoy. Run it with the example config file. + +```bash +go test test/e2e_authorized_test.go test/common.go +```