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.
The plugin has been completed and may be updated in the future.
The client sets credentials in Authorization
header in the following format:
credentials := Basic base64(username:password)
An example of the Authorization
header is as follows (Zm9vOmJhcg==
, which is the base64-encoded value of foo:bar
):
Authorization: Basic Zm9vOmJhcg==
Configure your envoy.yaml to set pairs of username and password.
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.
make build
make run
This test case is based on a local Envoy. Run it with the example config file.
make test