Skip to content

Commit 8107c1b

Browse files
committed
feat(xds): Update Envoy proto definitions and add ExtAuthz gRPC service
This commit updates the Envoy proto definitions to a newer version and adds the generated gRPC code for the `envoy.service.auth.v3.Authorization` service. The updated proto definitions include changes to the `ext_authz` filter, `GrpcService` configuration, and other related components. This also includes new proto files for gRPC credentials and header mutation rules. The generated `AuthorizationGrpc.java` file provides the gRPC stub that will be used to communicate with the external authorization service.
1 parent d50098f commit 8107c1b

File tree

31 files changed

+1828
-69
lines changed

31 files changed

+1828
-69
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ MODULE.bazel.lock
3131
.gitignore
3232
bin
3333

34+
# VsCode
35+
.vscode
36+
3437
# OS X
3538
.DS_Store
3639

Lines changed: 377 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,377 @@
1+
package io.envoyproxy.envoy.service.auth.v3;
2+
3+
import static io.grpc.MethodDescriptor.generateFullMethodName;
4+
5+
/**
6+
* <pre>
7+
* A generic interface for performing authorization check on incoming
8+
* requests to a networked service.
9+
* </pre>
10+
*/
11+
@io.grpc.stub.annotations.GrpcGenerated
12+
public final class AuthorizationGrpc {
13+
14+
private AuthorizationGrpc() {}
15+
16+
public static final java.lang.String SERVICE_NAME = "envoy.service.auth.v3.Authorization";
17+
18+
// Static method descriptors that strictly reflect the proto.
19+
private static volatile io.grpc.MethodDescriptor<io.envoyproxy.envoy.service.auth.v3.CheckRequest,
20+
io.envoyproxy.envoy.service.auth.v3.CheckResponse> getCheckMethod;
21+
22+
@io.grpc.stub.annotations.RpcMethod(
23+
fullMethodName = SERVICE_NAME + '/' + "Check",
24+
requestType = io.envoyproxy.envoy.service.auth.v3.CheckRequest.class,
25+
responseType = io.envoyproxy.envoy.service.auth.v3.CheckResponse.class,
26+
methodType = io.grpc.MethodDescriptor.MethodType.UNARY)
27+
public static io.grpc.MethodDescriptor<io.envoyproxy.envoy.service.auth.v3.CheckRequest,
28+
io.envoyproxy.envoy.service.auth.v3.CheckResponse> getCheckMethod() {
29+
io.grpc.MethodDescriptor<io.envoyproxy.envoy.service.auth.v3.CheckRequest, io.envoyproxy.envoy.service.auth.v3.CheckResponse> getCheckMethod;
30+
if ((getCheckMethod = AuthorizationGrpc.getCheckMethod) == null) {
31+
synchronized (AuthorizationGrpc.class) {
32+
if ((getCheckMethod = AuthorizationGrpc.getCheckMethod) == null) {
33+
AuthorizationGrpc.getCheckMethod = getCheckMethod =
34+
io.grpc.MethodDescriptor.<io.envoyproxy.envoy.service.auth.v3.CheckRequest, io.envoyproxy.envoy.service.auth.v3.CheckResponse>newBuilder()
35+
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
36+
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "Check"))
37+
.setSampledToLocalTracing(true)
38+
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
39+
io.envoyproxy.envoy.service.auth.v3.CheckRequest.getDefaultInstance()))
40+
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
41+
io.envoyproxy.envoy.service.auth.v3.CheckResponse.getDefaultInstance()))
42+
.setSchemaDescriptor(new AuthorizationMethodDescriptorSupplier("Check"))
43+
.build();
44+
}
45+
}
46+
}
47+
return getCheckMethod;
48+
}
49+
50+
/**
51+
* Creates a new async stub that supports all call types for the service
52+
*/
53+
public static AuthorizationStub newStub(io.grpc.Channel channel) {
54+
io.grpc.stub.AbstractStub.StubFactory<AuthorizationStub> factory =
55+
new io.grpc.stub.AbstractStub.StubFactory<AuthorizationStub>() {
56+
@java.lang.Override
57+
public AuthorizationStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
58+
return new AuthorizationStub(channel, callOptions);
59+
}
60+
};
61+
return AuthorizationStub.newStub(factory, channel);
62+
}
63+
64+
/**
65+
* Creates a new blocking-style stub that supports all types of calls on the service
66+
*/
67+
public static AuthorizationBlockingV2Stub newBlockingV2Stub(
68+
io.grpc.Channel channel) {
69+
io.grpc.stub.AbstractStub.StubFactory<AuthorizationBlockingV2Stub> factory =
70+
new io.grpc.stub.AbstractStub.StubFactory<AuthorizationBlockingV2Stub>() {
71+
@java.lang.Override
72+
public AuthorizationBlockingV2Stub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
73+
return new AuthorizationBlockingV2Stub(channel, callOptions);
74+
}
75+
};
76+
return AuthorizationBlockingV2Stub.newStub(factory, channel);
77+
}
78+
79+
/**
80+
* Creates a new blocking-style stub that supports unary and streaming output calls on the service
81+
*/
82+
public static AuthorizationBlockingStub newBlockingStub(
83+
io.grpc.Channel channel) {
84+
io.grpc.stub.AbstractStub.StubFactory<AuthorizationBlockingStub> factory =
85+
new io.grpc.stub.AbstractStub.StubFactory<AuthorizationBlockingStub>() {
86+
@java.lang.Override
87+
public AuthorizationBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
88+
return new AuthorizationBlockingStub(channel, callOptions);
89+
}
90+
};
91+
return AuthorizationBlockingStub.newStub(factory, channel);
92+
}
93+
94+
/**
95+
* Creates a new ListenableFuture-style stub that supports unary calls on the service
96+
*/
97+
public static AuthorizationFutureStub newFutureStub(
98+
io.grpc.Channel channel) {
99+
io.grpc.stub.AbstractStub.StubFactory<AuthorizationFutureStub> factory =
100+
new io.grpc.stub.AbstractStub.StubFactory<AuthorizationFutureStub>() {
101+
@java.lang.Override
102+
public AuthorizationFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
103+
return new AuthorizationFutureStub(channel, callOptions);
104+
}
105+
};
106+
return AuthorizationFutureStub.newStub(factory, channel);
107+
}
108+
109+
/**
110+
* <pre>
111+
* A generic interface for performing authorization check on incoming
112+
* requests to a networked service.
113+
* </pre>
114+
*/
115+
public interface AsyncService {
116+
117+
/**
118+
* <pre>
119+
* Performs authorization check based on the attributes associated with the
120+
* incoming request, and returns status `OK` or not `OK`.
121+
* </pre>
122+
*/
123+
default void check(io.envoyproxy.envoy.service.auth.v3.CheckRequest request,
124+
io.grpc.stub.StreamObserver<io.envoyproxy.envoy.service.auth.v3.CheckResponse> responseObserver) {
125+
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getCheckMethod(), responseObserver);
126+
}
127+
}
128+
129+
/**
130+
* Base class for the server implementation of the service Authorization.
131+
* <pre>
132+
* A generic interface for performing authorization check on incoming
133+
* requests to a networked service.
134+
* </pre>
135+
*/
136+
public static abstract class AuthorizationImplBase
137+
implements io.grpc.BindableService, AsyncService {
138+
139+
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
140+
return AuthorizationGrpc.bindService(this);
141+
}
142+
}
143+
144+
/**
145+
* A stub to allow clients to do asynchronous rpc calls to service Authorization.
146+
* <pre>
147+
* A generic interface for performing authorization check on incoming
148+
* requests to a networked service.
149+
* </pre>
150+
*/
151+
public static final class AuthorizationStub
152+
extends io.grpc.stub.AbstractAsyncStub<AuthorizationStub> {
153+
private AuthorizationStub(
154+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
155+
super(channel, callOptions);
156+
}
157+
158+
@java.lang.Override
159+
protected AuthorizationStub build(
160+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
161+
return new AuthorizationStub(channel, callOptions);
162+
}
163+
164+
/**
165+
* <pre>
166+
* Performs authorization check based on the attributes associated with the
167+
* incoming request, and returns status `OK` or not `OK`.
168+
* </pre>
169+
*/
170+
public void check(io.envoyproxy.envoy.service.auth.v3.CheckRequest request,
171+
io.grpc.stub.StreamObserver<io.envoyproxy.envoy.service.auth.v3.CheckResponse> responseObserver) {
172+
io.grpc.stub.ClientCalls.asyncUnaryCall(
173+
getChannel().newCall(getCheckMethod(), getCallOptions()), request, responseObserver);
174+
}
175+
}
176+
177+
/**
178+
* A stub to allow clients to do synchronous rpc calls to service Authorization.
179+
* <pre>
180+
* A generic interface for performing authorization check on incoming
181+
* requests to a networked service.
182+
* </pre>
183+
*/
184+
public static final class AuthorizationBlockingV2Stub
185+
extends io.grpc.stub.AbstractBlockingStub<AuthorizationBlockingV2Stub> {
186+
private AuthorizationBlockingV2Stub(
187+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
188+
super(channel, callOptions);
189+
}
190+
191+
@java.lang.Override
192+
protected AuthorizationBlockingV2Stub build(
193+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
194+
return new AuthorizationBlockingV2Stub(channel, callOptions);
195+
}
196+
197+
/**
198+
* <pre>
199+
* Performs authorization check based on the attributes associated with the
200+
* incoming request, and returns status `OK` or not `OK`.
201+
* </pre>
202+
*/
203+
public io.envoyproxy.envoy.service.auth.v3.CheckResponse check(io.envoyproxy.envoy.service.auth.v3.CheckRequest request) throws io.grpc.StatusException {
204+
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
205+
getChannel(), getCheckMethod(), getCallOptions(), request);
206+
}
207+
}
208+
209+
/**
210+
* A stub to allow clients to do limited synchronous rpc calls to service Authorization.
211+
* <pre>
212+
* A generic interface for performing authorization check on incoming
213+
* requests to a networked service.
214+
* </pre>
215+
*/
216+
public static final class AuthorizationBlockingStub
217+
extends io.grpc.stub.AbstractBlockingStub<AuthorizationBlockingStub> {
218+
private AuthorizationBlockingStub(
219+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
220+
super(channel, callOptions);
221+
}
222+
223+
@java.lang.Override
224+
protected AuthorizationBlockingStub build(
225+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
226+
return new AuthorizationBlockingStub(channel, callOptions);
227+
}
228+
229+
/**
230+
* <pre>
231+
* Performs authorization check based on the attributes associated with the
232+
* incoming request, and returns status `OK` or not `OK`.
233+
* </pre>
234+
*/
235+
public io.envoyproxy.envoy.service.auth.v3.CheckResponse check(io.envoyproxy.envoy.service.auth.v3.CheckRequest request) {
236+
return io.grpc.stub.ClientCalls.blockingUnaryCall(
237+
getChannel(), getCheckMethod(), getCallOptions(), request);
238+
}
239+
}
240+
241+
/**
242+
* A stub to allow clients to do ListenableFuture-style rpc calls to service Authorization.
243+
* <pre>
244+
* A generic interface for performing authorization check on incoming
245+
* requests to a networked service.
246+
* </pre>
247+
*/
248+
public static final class AuthorizationFutureStub
249+
extends io.grpc.stub.AbstractFutureStub<AuthorizationFutureStub> {
250+
private AuthorizationFutureStub(
251+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
252+
super(channel, callOptions);
253+
}
254+
255+
@java.lang.Override
256+
protected AuthorizationFutureStub build(
257+
io.grpc.Channel channel, io.grpc.CallOptions callOptions) {
258+
return new AuthorizationFutureStub(channel, callOptions);
259+
}
260+
261+
/**
262+
* <pre>
263+
* Performs authorization check based on the attributes associated with the
264+
* incoming request, and returns status `OK` or not `OK`.
265+
* </pre>
266+
*/
267+
public com.google.common.util.concurrent.ListenableFuture<io.envoyproxy.envoy.service.auth.v3.CheckResponse> check(
268+
io.envoyproxy.envoy.service.auth.v3.CheckRequest request) {
269+
return io.grpc.stub.ClientCalls.futureUnaryCall(
270+
getChannel().newCall(getCheckMethod(), getCallOptions()), request);
271+
}
272+
}
273+
274+
private static final int METHODID_CHECK = 0;
275+
276+
private static final class MethodHandlers<Req, Resp> implements
277+
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
278+
io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
279+
io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
280+
io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
281+
private final AsyncService serviceImpl;
282+
private final int methodId;
283+
284+
MethodHandlers(AsyncService serviceImpl, int methodId) {
285+
this.serviceImpl = serviceImpl;
286+
this.methodId = methodId;
287+
}
288+
289+
@java.lang.Override
290+
@java.lang.SuppressWarnings("unchecked")
291+
public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
292+
switch (methodId) {
293+
case METHODID_CHECK:
294+
serviceImpl.check((io.envoyproxy.envoy.service.auth.v3.CheckRequest) request,
295+
(io.grpc.stub.StreamObserver<io.envoyproxy.envoy.service.auth.v3.CheckResponse>) responseObserver);
296+
break;
297+
default:
298+
throw new AssertionError();
299+
}
300+
}
301+
302+
@java.lang.Override
303+
@java.lang.SuppressWarnings("unchecked")
304+
public io.grpc.stub.StreamObserver<Req> invoke(
305+
io.grpc.stub.StreamObserver<Resp> responseObserver) {
306+
switch (methodId) {
307+
default:
308+
throw new AssertionError();
309+
}
310+
}
311+
}
312+
313+
public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) {
314+
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
315+
.addMethod(
316+
getCheckMethod(),
317+
io.grpc.stub.ServerCalls.asyncUnaryCall(
318+
new MethodHandlers<
319+
io.envoyproxy.envoy.service.auth.v3.CheckRequest,
320+
io.envoyproxy.envoy.service.auth.v3.CheckResponse>(
321+
service, METHODID_CHECK)))
322+
.build();
323+
}
324+
325+
private static abstract class AuthorizationBaseDescriptorSupplier
326+
implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
327+
AuthorizationBaseDescriptorSupplier() {}
328+
329+
@java.lang.Override
330+
public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
331+
return io.envoyproxy.envoy.service.auth.v3.ExternalAuthProto.getDescriptor();
332+
}
333+
334+
@java.lang.Override
335+
public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
336+
return getFileDescriptor().findServiceByName("Authorization");
337+
}
338+
}
339+
340+
private static final class AuthorizationFileDescriptorSupplier
341+
extends AuthorizationBaseDescriptorSupplier {
342+
AuthorizationFileDescriptorSupplier() {}
343+
}
344+
345+
private static final class AuthorizationMethodDescriptorSupplier
346+
extends AuthorizationBaseDescriptorSupplier
347+
implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
348+
private final java.lang.String methodName;
349+
350+
AuthorizationMethodDescriptorSupplier(java.lang.String methodName) {
351+
this.methodName = methodName;
352+
}
353+
354+
@java.lang.Override
355+
public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
356+
return getServiceDescriptor().findMethodByName(methodName);
357+
}
358+
}
359+
360+
private static volatile io.grpc.ServiceDescriptor serviceDescriptor;
361+
362+
public static io.grpc.ServiceDescriptor getServiceDescriptor() {
363+
io.grpc.ServiceDescriptor result = serviceDescriptor;
364+
if (result == null) {
365+
synchronized (AuthorizationGrpc.class) {
366+
result = serviceDescriptor;
367+
if (result == null) {
368+
serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
369+
.setSchemaDescriptor(new AuthorizationFileDescriptorSupplier())
370+
.addMethod(getCheckMethod())
371+
.build();
372+
}
373+
}
374+
}
375+
return result;
376+
}
377+
}

0 commit comments

Comments
 (0)