-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |