OAuth2

    • This filter should be configured with the name envoy.filters.http.oauth2.

    The OAuth filter’s flow involves:

    • After a successful login, the authn server should be configured to redirect the user back to the redirect_uri provided in the query string in the first step. In the below code example, we choose /callback as the configured match path. An “authorization grant” is included in the query string for this second redirect.

    • Using this new grant and the , the filter then attempts to retrieve an access token from the token_endpoint. The filter knows it has to do this instead of reinitiating another login because the incoming request has a path that matches the criteria.

    • The filter calls continueDecoding() to unblock the filter chain.

    When the authn server validates the client and returns an authorization token back to the OAuth filter, no matter what format that token is, if forward_bearer_token is set to true the filter will send over a cookie named to the upstream. Additionally, the header will be populated with the same value.

    Attention

    The following is an example configuring the filter.

    Below is a complete code example of how we employ the filter as one of

    Finally, the following code block illustrates sample contents inside a yaml file containing both credential secrets. Both the token_secret and the can be defined in one shared file.

    When enabled, the OAuth filter does not protect against Cross-Site-Request-Forgery attacks on domains with cached authentication (in the form of cookies). It is recommended to pair this filter with the CSRF Filter to prevent malicious social engineering.

    The service must be served over HTTPS for this filter to work properly, as the cookies use . Without https, your provider will likely reject the incoming request, and your access cookies will not be cached to bypass future logins.

    The signout path will redirect the current user to ‘/’, and clear all authentication cookies related to the HMAC validation. Consequently, the OAuth filter will then restart the full OAuth flow at the root path, sending the user to the configured auth endpoint.

    pass_through_matcher provides an interface for users to provide specific header matching criteria such that, when applicable, the OAuth flow is entirely skipped. When this occurs, the metric is still incremented.

    Generally, allowlisting is inadvisable from a security standpoint.

    The OAuth2 filter outputs statistics in the <stat_prefix>. namespace.