-
Notifications
You must be signed in to change notification settings - Fork 4k
xds: Add configuration objects for ExtAuthz, GrpcService and Bootstrap changes for GrpcService #12492
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
Merged
Merged
xds: Add configuration objects for ExtAuthz, GrpcService and Bootstrap changes for GrpcService #12492
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4baea6b
feat(xds): Add configuration objects for ExtAuthz and GrpcService
sauravzg 5654c64
Fixup: Address comments from #12492
sauravzg 5ed6993
Fixup: 12492 Split HeaderValueValidationUtils to GrpcService to match…
sauravzg 35f3956
Fixup: 12492 Remove artifact from old channelcreds implementation an…
sauravzg 1d4e48b
Fixup 12492: Use builder instead of newBuilder
sauravzg c1b95f1
Fixup: 12492 Fix callcredentials to not apply instead of erroring out…
sauravzg b28bd3c
Fixup 12492: Refactor `allowedGrpcService` to be non optional and fix…
sauravzg 779b8ed
Fixup 12492: Address copilot comments
sauravzg 804cb09
Fixup 12492: Eliminate bootstrap dependency on grpc
sauravzg b330585
Fixup 12492: Eliminate GrpcService..Provider classes
sauravzg c65464a
Fixup 12492: Improve test coverage for config parser
sauravzg d59c705
Fixup 12492: Eliminate cyclic dependencies
sauravzg 7cd9595
Fixup #12492: Address gemini assist comments about runtime exception …
sauravzg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
xds/src/main/java/io/grpc/xds/ExtAuthzConfigParser.java
This file contains hidden or 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,103 @@ | ||
| /* | ||
| * Copyright 2025 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc.xds; | ||
|
|
||
| import com.google.common.collect.ImmutableList; | ||
| import io.envoyproxy.envoy.extensions.filters.http.ext_authz.v3.ExtAuthz; | ||
| import io.grpc.internal.GrpcUtil; | ||
| import io.grpc.xds.client.Bootstrapper.BootstrapInfo; | ||
| import io.grpc.xds.client.Bootstrapper.ServerInfo; | ||
| import io.grpc.xds.internal.MatcherParser; | ||
| import io.grpc.xds.internal.extauthz.ExtAuthzConfig; | ||
| import io.grpc.xds.internal.extauthz.ExtAuthzParseException; | ||
| import io.grpc.xds.internal.grpcservice.GrpcServiceConfig; | ||
| import io.grpc.xds.internal.grpcservice.GrpcServiceParseException; | ||
| import io.grpc.xds.internal.headermutations.HeaderMutationRulesParseException; | ||
| import io.grpc.xds.internal.headermutations.HeaderMutationRulesParser; | ||
|
|
||
|
|
||
| /** | ||
| * Parser for {@link io.envoyproxy.envoy.extensions.filters.http.ext_authz.v3.ExtAuthz}. | ||
| */ | ||
| final class ExtAuthzConfigParser { | ||
|
|
||
| private ExtAuthzConfigParser() {} | ||
|
|
||
| /** | ||
| * Parses the {@link io.envoyproxy.envoy.extensions.filters.http.ext_authz.v3.ExtAuthz} proto to | ||
| * create an {@link ExtAuthzConfig} instance. | ||
| * | ||
| * @param extAuthzProto The ext_authz proto to parse. | ||
| * @return An {@link ExtAuthzConfig} instance. | ||
| * @throws ExtAuthzParseException if the proto is invalid or contains unsupported features. | ||
| */ | ||
| public static ExtAuthzConfig parse( | ||
| ExtAuthz extAuthzProto, BootstrapInfo bootstrapInfo, ServerInfo serverInfo) | ||
| throws ExtAuthzParseException { | ||
| if (!extAuthzProto.hasGrpcService()) { | ||
| throw new ExtAuthzParseException( | ||
| "unsupported ExtAuthz service type: only grpc_service is supported"); | ||
| } | ||
| GrpcServiceConfig grpcServiceConfig; | ||
| try { | ||
| grpcServiceConfig = | ||
| GrpcServiceConfigParser.parse(extAuthzProto.getGrpcService(), bootstrapInfo, serverInfo); | ||
| } catch (GrpcServiceParseException e) { | ||
| throw new ExtAuthzParseException("Failed to parse GrpcService config: " + e.getMessage(), e); | ||
| } | ||
| ExtAuthzConfig.Builder builder = ExtAuthzConfig.builder().grpcService(grpcServiceConfig) | ||
| .failureModeAllow(extAuthzProto.getFailureModeAllow()) | ||
| .failureModeAllowHeaderAdd(extAuthzProto.getFailureModeAllowHeaderAdd()) | ||
| .includePeerCertificate(extAuthzProto.getIncludePeerCertificate()) | ||
| .denyAtDisable(extAuthzProto.getDenyAtDisable().getDefaultValue().getValue()); | ||
|
|
||
| if (extAuthzProto.hasFilterEnabled()) { | ||
| try { | ||
| builder.filterEnabled( | ||
| MatcherParser.parseFractionMatcher(extAuthzProto.getFilterEnabled().getDefaultValue())); | ||
| } catch (IllegalArgumentException e) { | ||
| throw new ExtAuthzParseException(e.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| if (extAuthzProto.hasStatusOnError()) { | ||
| builder.statusOnError( | ||
| GrpcUtil.httpStatusToGrpcStatus(extAuthzProto.getStatusOnError().getCodeValue())); | ||
| } | ||
|
|
||
| if (extAuthzProto.hasAllowedHeaders()) { | ||
| builder.allowedHeaders(extAuthzProto.getAllowedHeaders().getPatternsList().stream() | ||
| .map(MatcherParser::parseStringMatcher).collect(ImmutableList.toImmutableList())); | ||
| } | ||
|
|
||
| if (extAuthzProto.hasDisallowedHeaders()) { | ||
| builder.disallowedHeaders(extAuthzProto.getDisallowedHeaders().getPatternsList().stream() | ||
| .map(MatcherParser::parseStringMatcher).collect(ImmutableList.toImmutableList())); | ||
| } | ||
|
|
||
| if (extAuthzProto.hasDecoderHeaderMutationRules()) { | ||
| try { | ||
| builder.decoderHeaderMutationRules( | ||
| HeaderMutationRulesParser.parse(extAuthzProto.getDecoderHeaderMutationRules())); | ||
| } catch (HeaderMutationRulesParseException e) { | ||
| throw new ExtAuthzParseException(e.getMessage(), e); | ||
| } | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
xds/src/main/java/io/grpc/xds/GrpcBootstrapImplConfig.java
This file contains hidden or 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,34 @@ | ||
| /* | ||
| * Copyright 2025 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc.xds; | ||
|
|
||
| import com.google.auto.value.AutoValue; | ||
| import io.grpc.Internal; | ||
| import io.grpc.xds.client.AllowedGrpcServices; | ||
|
|
||
| /** | ||
| * Custom configuration for gRPC xDS bootstrap implementation. | ||
| */ | ||
| @Internal | ||
| @AutoValue | ||
| public abstract class GrpcBootstrapImplConfig { | ||
| public abstract AllowedGrpcServices allowedGrpcServices(); | ||
|
|
||
| public static GrpcBootstrapImplConfig create(AllowedGrpcServices services) { | ||
| return new AutoValue_GrpcBootstrapImplConfig(services); | ||
| } | ||
| } |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.