forked from envoyproxy/envoy
-
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.
feat: credential injector impl (envoyproxy#30850)
* credential injector impl Signed-off-by: huabing zhao <zhaohuabing@gmail.com> --------- Signed-off-by: huabing zhao <zhaohuabing@gmail.com> Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Co-authored-by: phlax <phlax@users.noreply.github.com> Co-authored-by: Adi (Suissa) Peleg <adip@google.com>
- Loading branch information
1 parent
aedebb0
commit c6b4239
Showing
40 changed files
with
1,300 additions
and
64 deletions.
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
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
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
File renamed without changes.
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
File renamed without changes.
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
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
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
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
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
8 changes: 8 additions & 0 deletions
8
docs/root/api-v3/config/injected_credentials/injected_credentials.rst
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Injected credentials | ||
==================== | ||
|
||
.. toctree:: | ||
:glob: | ||
:maxdepth: 2 | ||
|
||
../../extensions/http/injected_credentials/*/v3/* |
57 changes: 57 additions & 0 deletions
57
docs/root/configuration/http/http_filters/_include/credential-injector-filter.yaml
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
static_resources: | ||
listeners: | ||
- name: listener_0 | ||
address: | ||
socket_address: | ||
address: 0.0.0.0 | ||
port_value: 10000 | ||
filter_chains: | ||
- filters: | ||
- name: envoy.filters.network.http_connection_manager | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager | ||
stat_prefix: ingress_http | ||
access_log: | ||
- name: envoy.access_loggers.stdout | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog | ||
route_config: | ||
name: local_route | ||
virtual_hosts: | ||
- name: local_service | ||
domains: ["*"] | ||
routes: | ||
- match: | ||
prefix: "/" | ||
route: | ||
cluster: service1 | ||
http_filters: | ||
- name: envoy.filters.http.credential_injector | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.http.credential_injector.v3.CredentialInjector | ||
allow_request_without_credential: true | ||
overwrite: true | ||
credential: | ||
name: envoy.http.injected_credentials.generic | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.http.injected_credentials.generic.v3.Generic | ||
credential: | ||
name: credential | ||
sds_config: | ||
path_config_source: | ||
path: /home/ubuntu/credential.yaml | ||
- name: envoy.filters.http.router | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router | ||
|
||
clusters: | ||
- name: service1 | ||
load_assignment: | ||
cluster_name: service1 | ||
endpoints: | ||
- lb_endpoints: | ||
- endpoint: | ||
address: | ||
socket_address: | ||
address: 127.0.0.1 | ||
port_value: 8080 |
73 changes: 73 additions & 0 deletions
73
docs/root/configuration/http/http_filters/credential_injector_filter.rst
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.. _config_http_filters_credential_injector: | ||
|
||
Credential Injector | ||
=================== | ||
|
||
The credential injector HTTP filter serves the purpose of injecting credentials into outgoing HTTP requests. | ||
|
||
The filter configuration is used to retrieve the credentials, or they can be fetched from a remote source | ||
such as an OAuth2 authorization server. The credentials obtained are then injected into the ``Authorization`` | ||
header of the proxied HTTP requests, utilizing either the ``Basic`` or ``Bearer`` scheme. | ||
|
||
Notice: This filter is intended to be used for workload authentication, which means that the identity associated | ||
with the inserted credential is considered as the identity of the workload behind the Envoy proxy (in this case, | ||
Envoy is typically deployed as a sidecar alongside that workload). | ||
|
||
.. note:: | ||
This filter does not handle end user authentication. | ||
|
||
The purpose of the filter is solely to authenticate the workload itself. | ||
|
||
Configuration | ||
------------- | ||
|
||
* This filter should be configured with the type URL ``type.googleapis.com/envoy.extensions.filters.http.credential_injector.v3.CredentialInjector``. | ||
* :ref:`v3 API reference <envoy_v3_api_msg_extensions.filters.http.credential_injector.v3.CredentialInjector>` | ||
|
||
Currently the filter supports :ref:`generic <envoy_v3_api_msg_extensions.http.injected_credentials.generic.v3.Generic>` only. | ||
Other credential types can be supported as extensions. | ||
|
||
Here is an example configuration with Generic credential, which injects an HTTP Basic Auth credential into the proxied requests. | ||
|
||
.. literalinclude:: _include/credential-injector-filter.yaml | ||
:language: yaml | ||
:lines: 28-41 | ||
:caption: :download:`credential-injector-filter.yaml <_include/credential-injector-filter.yaml>` | ||
|
||
|
||
credential.yaml for Basic Auth: | ||
|
||
.. code-block:: yaml | ||
resources: | ||
- "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret" | ||
name: credential | ||
generic_secret: | ||
secret: | ||
inline_string: "Basic base64EncodedUsernamePassword" | ||
It can also be configured to inject a Bearer token into the proxied requests. | ||
|
||
credential.yaml for Bearer Token: | ||
|
||
.. code-block:: yaml | ||
resources: | ||
- "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret" | ||
name: credential | ||
generic_secret: | ||
secret: | ||
inline_string: "Bearer myToken" | ||
Statistics | ||
---------- | ||
|
||
The HTTP credential injector filter outputs statistics in the ``http.<stat_prefix>.credential_injector.`` namespace. | ||
|
||
.. csv-table:: | ||
:header: Name, Type, Description | ||
:widths: 1, 1, 2 | ||
|
||
``injected``, Counter, Total number of requests with injected credentials | ||
``failed``, Counter, Total number of requests that failed to inject credentials | ||
``already_exists``, Counter, Total number of requests that already had credentials and overwrite is false |
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
Oops, something went wrong.