Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spiffe: add support for spiffe bundle format #36190

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

briansonnenberg
Copy link
Contributor

@briansonnenberg briansonnenberg commented Sep 18, 2024

Commit Message: Adds alternative to "trust_domains" config for the spiffe validator—"trust_bundle_map".

Additional Description:

#35567
trust_bundle_map points to a local file containing a SPIFFE bundle map. A file watcher is set up to trigger refreshes to the SPIFFE data when this file is modified. SPIFFE refresh hint and sequence number are currently ignored.

Risk Level: medium
Testing: WIP
Docs Changes: TBD
Release Notes: TBD

Copy link

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

🐱

Caused by: #36190 was opened by briansonnenberg.

see: more, trace.

@jmarantz
Copy link
Contributor

/wait

@@ -57,4 +82,9 @@ message SPIFFECertValidatorConfig {

// This field specifies trust domains used for validating incoming X.509-SVID(s).
repeated TrustDomain trust_domains = 1 [(validate.rules).repeated = {min_items: 1}];
Copy link
Member

Choose a reason for hiding this comment

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

I think the min_items validation should be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It still doesn't make sense to include trust_domains with no entries, so I think we should keep it. It only applies if trust_domains is specified in the config.

Copy link
Member

@wbpcode wbpcode Sep 27, 2024

Choose a reason for hiding this comment

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

Considering the users who want to use the new trust_bundles, they still need to configure at least one item at the trust_domains, it's no doubt unexpected way.

Now, you need to do the validation in your code rather then the PGV. You need to check if the trust_bundles is set or not. If it's not set, then you should check the length of trust_domains to have at least one item. If the trust_bundles is set, then you can ignore the trust_domains.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They don't need to configure any trust_domains though? Unless I'm missing something in my testing, but I haven't had to configure any. It only applies if someone were to configure an empty list of trust_domains explicitly along with their trust_bundles.

Copy link
Member

Choose a reason for hiding this comment

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

I create a unit test in my local env with similar scenario. They throw same error:

TEST_F(RateLimitConfigTest, Test) {
  const std::string yaml = R"EOF(
  rate_limits: []
  )EOF";
  test::extensions::filters::common::ratelimit_config::TestRateLimitConfig proto_config;
  TestUtility::loadFromYamlAndValidate(yaml, proto_config);
}

TEST_F(RateLimitConfigTest, Test2) {
  const std::string yaml = R"EOF(
  {}
  )EOF";
  test::extensions::filters::common::ratelimit_config::TestRateLimitConfig proto_config;
  TestUtility::loadFromYamlAndValidate(yaml, proto_config);
}
C++ exception with description "Proto constraint validation failed (TestRateLimitConfigValidationError.RateLimits: value must contain at least 1 item(s)): " thrown in the test body.

Copy link
Member

Choose a reason for hiding this comment

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

I believe you may need to remove the PGV validation and add conditional check in your code.

And you also need to add some tests to ensure your new field is work as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will remove the check, but this is the config I have been using and it's working:

              validation_context:
                allow_expired_certificate: true
                custom_validator_config:
                  name: envoy.tls.cert_validator.spiffe
                  typed_config:
                    "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.SPIFFECertValidatorConfig
                    trust_bundle_map:
                      filename: "<snip>/jwks_map.json"

Copy link
Member

Choose a reason for hiding this comment

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

then, it's a little weird. 🤔

Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. some new comments to the API to start the review. And please address the comment from @markdroth .

@markdroth
Copy link
Contributor

/lgtm api

@kyessenov
Copy link
Contributor

Please merge main.
/wait

@alyssawilk
Copy link
Contributor

/wait on CI

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.

6 participants