Skip to content

feat: api for credential injector http filter#27769

Merged
adisuissa merged 21 commits intoenvoyproxy:mainfrom
zhaohuabing:credential_injector_api
Nov 9, 2023
Merged

feat: api for credential injector http filter#27769
adisuissa merged 21 commits intoenvoyproxy:mainfrom
zhaohuabing:credential_injector_api

Conversation

@zhaohuabing
Copy link
Copy Markdown
Member

@zhaohuabing zhaohuabing commented Jun 2, 2023

API for the credential injector HTTP filter.

Note: based on feedback in the comments, the original PR has been split into multiple PRs, this one only contains APIs so it would be easier to review. The implementations of the Credential Injector Filter and Extensions will be in follow-up PRs.

Commit Message: add API for the credential injector HTTP filter.

Additional Description:
The credential injector HTTP filter serves the purpose of injecting credentials into outgoing HTTP requests. At present, the filter configuration is used to retrieve the credentials, or they can be requested through the OAuth2 client credential grant. Furthermore, it has the potential to support additional credential sources in the future, such as the OAuth2 resource owner password credentials grant , STS, etc. 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). Please note that this filter does not handle end user authentication. Its purpose is solely to authenticate the workload itself.

Sponsor: @kyessenov kindly offered to be the sponsor of this new filter.

Risk Level: low
Testing: no, only APIs, testing will be in follow-up PRs with implementation.
Docs Changes: yes
Release Notes: no
Platform Specific Features: No
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

generic, can be used to inject a custom credential in any specified header

          http_filters:
          - name: envoy.filters.http.credential_injector
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.credential_injector.v3.CredentialInjector
              overwrite: false
              credential:
                name:  custom_credential      
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.credentials.generic.v3.Generic
                  header: my_custom_credential_header // default "Authorization"
                  credential:
                    name: my_credential
                    sds_config:
                      path_config_source:
                        path: /home/ubuntu/credential.yaml

basic auth, used to inject HTTP basic auth credential(username password)

          http_filters:
          - name: envoy.filters.http.credential_injector
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.credential_injector.v3.CredentialInjector
              overwrite: false
              credential:
                name: basic_auth      
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.credentials.basic_auth.v3.BasicAuth
                  username: test
                  password:
                    name: password
                    sds_config:
                      path_config_source:
                        path: /home/ubuntu/password.yaml

bearer token, used to inject HTTP bearer token

          http_filters:
          - name: envoy.filters.http.credential_injector
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.credential_injector.v3.CredentialInjector
              overwrite: false
              credential:
                name: bearer_token      
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.credentials.bearer_token.v3.BearerToken
                  bearer_token:
                    name: bearer_token
                    sds_config:
                      path_config_source:
                        path: /home/ubuntu/bearer_token.yaml

oauth2, used to get token via oauth2 client credentials grant and inject it into the http header

          http_filters:
          - name: envoy.filters.http.credential_injector
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.credential_injector.v3.CredentialInjector
              overwrite: false
              credential:
                name: oauth2      
                typed_config:
                  "@type": type.googleapis.com/envoy.extensions.credentials.oauth2.v3.OAuth2
                  token_endpoint: https://foo.bar.com/oauth
                  client_credentials:
                    client_id: my_client_id
                    client_secret: 
                       name: client_secret
                      sds_config:
                       ..... //omitted for brevity

@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @lizan
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #27769 was opened by zhaohuabing.

see: more, trace.

@zhaohuabing zhaohuabing force-pushed the credential_injector_api branch 2 times, most recently from 91faebe to 3a6f1fe Compare June 2, 2023 09:29
@zhaohuabing zhaohuabing marked this pull request as draft June 2, 2023 09:48
@zhaohuabing zhaohuabing force-pushed the credential_injector_api branch 5 times, most recently from cb5ad8a to 3638f5e Compare June 3, 2023 15:05
@zhaohuabing zhaohuabing changed the title API for the credential injector http filter api: credential injector http filter Jun 3, 2023
@zhaohuabing zhaohuabing marked this pull request as ready for review June 6, 2023 01:42
@zhaohuabing
Copy link
Copy Markdown
Member Author

zhaohuabing commented Jun 9, 2023

Need help here. Precheck protobuf failed but the log doesn't give explicit reasons.
https://dev.azure.com/cncf/envoy/_build/results?buildId=139531&view=logs&j=c95d62a5-6bb9-58f0-2a02-7575fd482a15&t=76c9b3e6-0d40-57e9-06f3-2219e9228a0a

@zhaohuabing zhaohuabing force-pushed the credential_injector_api branch 2 times, most recently from 2b04b1b to 52ba2f7 Compare June 9, 2023 10:13
@zhaohuabing zhaohuabing force-pushed the credential_injector_api branch 4 times, most recently from be739c8 to e6edf1d Compare June 10, 2023 04:24
@KBaichoo
Copy link
Copy Markdown
Contributor

ping @lizan on api
ping @kyessenov if there's additional review

Copy link
Copy Markdown
Contributor

@kyessenov kyessenov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. Need API reviewers feedback.

Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in good direction, do you have a draft for the implementation so I can refer for those API?

@zhaohuabing
Copy link
Copy Markdown
Member Author

zhaohuabing commented Jun 17, 2023 via email

@zhaohuabing
Copy link
Copy Markdown
Member Author

zhaohuabing commented Jun 17, 2023 via email

Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
@zhaohuabing
Copy link
Copy Markdown
Member Author

zhaohuabing commented Oct 25, 2023

Looking at the implementation of these two injector and they are pretty similar. We should be able to refactor them into one similar implementation.

@lizan I moved the shared code from those extensions into the common directory to reduce redundancy. Does this address your concern?

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Oct 26, 2023

I agree with @adisuissa's suggestion, this patch is huge and it would be better to split it to multiple different parts. Then we do more reasonable review.

And compared to implementation, we should try to figure out a final conclusion of the API first. Seems the discussion about the API has not ended.

@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Oct 26, 2023

/wait-any

@zhaohuabing
Copy link
Copy Markdown
Member Author

zhaohuabing commented Oct 26, 2023

/lgtm api

This looks much cleaner, thank you!

@wbpcode @adisuissa Thanks for your suggestion. We have already agreed on the APIs before I push implementations into this PR, please see the above discussion on the APIs.

If this is too big for review, I can split this into multiple PRs. This one is just for APIs, and Filter and Extensions implementation will be in follow-up PRs.

Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the directory name is confusing, as these are only credentials that are injected (not being fetched IIUC). Please change the directory name from api/envoy/extensions/credentials/ to api/envoy/extensions/injected_credentials/

Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
@phlax
Copy link
Copy Markdown
Member

phlax commented Oct 31, 2023

/docs

@repokitteh-read-only
Copy link
Copy Markdown

Docs for this Pull Request will be rendered here:

https://storage.googleapis.com/envoy-pr/27769/docs/index.html

The docs are (re-)rendered each time the CI envoy-presubmit (precheck docs) job completes.

🐱

Caused by: a #27769 (comment) was created by @phlax.

see: more, trace.

Signed-off-by: huabing zhao <zhaohuabing@gmail.com>
Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm api

defer to @adisuissa

@kyessenov
Copy link
Copy Markdown
Contributor

/wait-any
for @adisuissa response

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, LGTM API. We can reiterate over the details as these are WIP.
Thanks!
/lgtm api

@zhaohuabing
Copy link
Copy Markdown
Member Author

zhaohuabing commented Nov 6, 2023

Thank guys for reviewing the PR and the help on the API!

Need your last help. How can I fix this to get this PR merged? I already added a new envoy.injected_credentials category in tools/extensions/extensions_schema.yaml.

Unable to find extension category:  envoy.injected_credentials

https://dev.azure.com/cncf/envoy/_build/results?buildId=154742&view=logs&j=9fd58ae0-0c50-56b1-f517-c2b9afda9c9b&t=f871f0ce-3dc6-5bd2-7916-5ec61dbe723c&l=138

As you suggested, the implementation of the credential injector and the generic credential extension will be in a follow-up PR soo after this PR gets merged.

Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.