Hello,
I am trying to figure out the best way to implement an authentication filter that takes an incoming HTTP request with a session token header, makes a call to a gRPC authentication service using that session token to authenticate, and then routes the original request to its destination with data from the authentication service injected into the outgoing request. From what I understand, I can implement a custom filter by building Envoy from source and writing a custom filter. I did however find an ext_authz filter linked in source already but with no documentation, and some proto files for an external_auth filter, also with no documentation. I'm wondering if either of these will be sufficient for my use case, and what the status of these implementations are. Let me first outline the use case clearly below:
1. An envoy listener receives a JSON-over-HTTP request destined for a gRPC service S, potentially with an X-Session-Token header
2. We run the JSON to gRPC transcoder filter to prepare the request to hit S
3. We then run our auth filter
a. If the X-Session-Token header does not exist, don't run the rest of the filter (but don't fail the request! some requests from the web are legitimately unauthenticated, and thats fine)
b. If it does exist, make a call to the gRPC authentication service. The authentication service is defined by the following proto:
service Authenticator {
rpc AuthenticateUser(AuthenticateUserRequest) returns (AuthenticateUserResponse) {}
}
message AuthenticateUserRequest {
string session_token = 1;
}
message AuthenticateUserResponse {
string auth_token = 1;
}
In other words, it takes a session token and returns a temporary expiring auth token, used as proof of authentication as the request travels from service to service.
4. We receive our response from the authentication service.
a. If we receive an error, return an error.
b. If successful, take the auth_token key from the response and add a corresponding gRPC metadata key "authToken" to the gRPC request
I know that I can always fall back to implementing a custom filter if all else fails, but I want to choose the path of least resistance. Do the ext_authz or external_auth filters allow some or all of this behavior, and if so which parts can they handle? Are there plans to implement this type of functionality if it doesnt currently exist right now?