Skip to content

Commit 98c7bdd

Browse files
authored
GRPC Passthrough documentation and test server update (#10676)
1 parent a1a5d36 commit 98c7bdd

File tree

16 files changed

+194
-87
lines changed

16 files changed

+194
-87
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
changelog:
2+
- type: NON_USER_FACING
3+
issueLink: https://github.com/solo-io/solo-projects/issues/7893
4+
resolvesIssue: false
5+
description: >-
6+
Update grpc and http passthrough example servers to optionlly log full request info
7+
Update grpc and http passthrough examples to be able to run at the same time.
8+
Update PassThroughGrpc description to call out use of `settings.extauth.requestBody` to send request body to extauth server.
9+
10+

docs/content/guides/security/auth/extauth/passthrough_auth/grpc/_index.md

+17-14
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ EOF
8181
Now let's configure Gloo Gateway to route requests to the upstream we just created. To do that, we define a simple Virtual
8282
Service to match all requests that:
8383

84-
- contain a `Host` header with value `foo` and
84+
- contain a `Host` header with value `foo-grpc` and
8585
- have a path that starts with `/` (this will match all requests).
8686

8787
Apply the following virtual service:
88-
{{< readfile file="guides/security/auth/extauth/basic_auth/test-no-auth-vs.yaml" markdown="true">}}
88+
{{< readfile file="guides/security/auth/extauth/passthrough_auth/grpc/test-no-auth-vs.yaml" markdown="true">}}
8989

9090
Let's send a request that matches the above route to the gateway proxy and make sure it works:
9191

9292
```shell
93-
curl -H "Host: foo" $(glooctl proxy url)/posts/1
93+
curl -H "Host: foo-grpc" $(glooctl proxy url)/posts/1
9494
```
9595

9696
The above command should produce the following output:
@@ -116,7 +116,7 @@ kubectl apply -f - <<EOF
116116
apiVersion: enterprise.gloo.solo.io/v1
117117
kind: AuthConfig
118118
metadata:
119-
name: passthrough-auth
119+
name: grpc-passthrough-auth
120120
namespace: gloo-system
121121
spec:
122122
configs:
@@ -141,12 +141,12 @@ kubectl apply -f - <<EOF
141141
apiVersion: gateway.solo.io/v1
142142
kind: VirtualService
143143
metadata:
144-
name: auth-tutorial
144+
name: grpc-auth-tutorial
145145
namespace: gloo-system
146146
spec:
147147
virtualHost:
148148
domains:
149-
- 'foo'
149+
- 'foo-grpc'
150150
routes:
151151
- matchers:
152152
- prefix: /
@@ -156,11 +156,11 @@ spec:
156156
name: json-upstream
157157
namespace: gloo-system
158158
options:
159-
autoHostRewrite: true
159+
autoHostRewrite: true
160160
options:
161161
extauth:
162162
configRef:
163-
name: passthrough-auth
163+
name: grpc-passthrough-auth
164164
namespace: gloo-system
165165
EOF
166166
{{< /highlight >}}
@@ -193,19 +193,19 @@ For more information on how Gloo Gateway handles observability and metrics, view
193193
The virtual service that we have created should now be secured using our external authentication service. To test this, we can try our original command, and the request should not be allowed through because of missing authentication.
194194

195195
```shell
196-
curl -H "Host: foo" $(glooctl proxy url)/posts/1
196+
curl -H "Host: foo-grpc" $(glooctl proxy url)/posts/1
197197
```
198198

199199
The output should be empty. In fact, we can see the 403 (Unauthorized) HTTP status code if we run the same curl, but with a modification to print the http code to the console.
200200

201201
```shell
202-
curl -s -o /dev/null -w "%{http_code}" -H "Host: foo" $(glooctl proxy url)/posts/1
202+
curl -s -o /dev/null -w "%{http_code}" -H "Host: foo-grpc" $(glooctl proxy url)/posts/1
203203
```
204204

205205
The sample gRPC authentication service has been implemented such that any request with the header `authorization: authorize me` will be authorized. We can easily add this header to our curl request as follows:
206206

207207
```shell
208-
curl -H "Host: foo" -H "authorization: authorize me" $(glooctl proxy url)/posts/1
208+
curl -H "Host: foo-grpc" -H "authorization: authorize me" $(glooctl proxy url)/posts/1
209209
```
210210

211211
The request should now be authorized!
@@ -223,7 +223,7 @@ You can configure the Gloo ExtAuth server to retry the connection to the passthr
223223
apiVersion: enterprise.gloo.solo.io/v1
224224
kind: AuthConfig
225225
metadata:
226-
name: passthrough-auth
226+
name: grpc-passthrough-auth
227227
namespace: gloo-system
228228
spec:
229229
configs:
@@ -262,7 +262,7 @@ State from other auth steps is sent to the passthrough service via [CheckRequest
262262

263263
State from the passthrough service can be sent to other auth steps via [CheckResponse DynamicMetadata](https://github.com/envoyproxy/envoy/blob/50e722cbb0486268c128b0f1d0ef76217387799f/api/envoy/service/auth/v3/external_auth.proto#L126) under a unique key: `solo.auth.passthrough`.
264264

265-
### Passing in custom configuration to Passthrough Auth Service from AuthConfigs
265+
### Passing custom configuration to the Passthrough Auth Service from AuthConfigs
266266
{{% notice note %}}
267267
This feature was introduced with **Gloo Gateway Enterprise**, release 1.6.15. If you are using an earlier version, this will not work.
268268
{{% /notice %}}
@@ -274,7 +274,7 @@ kubectl apply -f - <<EOF
274274
apiVersion: enterprise.gloo.solo.io/v1
275275
kind: AuthConfig
276276
metadata:
277-
name: passthrough-auth
277+
name: grpc-passthrough-auth
278278
namespace: gloo-system
279279
spec:
280280
configs:
@@ -292,6 +292,9 @@ EOF
292292

293293
This config is accessible via the [CheckRequest FilterMetadata](https://github.com/envoyproxy/envoy/blob/50e722cbb0486268c128b0f1d0ef76217387799f/api/envoy/service/auth/v3/external_auth.proto#L36) under a unique key: `solo.auth.passthrough.config`.
294294

295+
## Pass request body to the Passthrough Auth Service
296+
In order for the body to be passed through to the auth service, the `settings.extauth.requestBody` must be set in the Gloo Gateway Settings CRD so that the request body is buffered and sent to the ext-auth service. Headers are always passed through.
297+
295298
## Summary
296299

297300
In this guide, we installed Gloo Gateway Enterprise and created an unauthenticated Virtual Service that routes requests to a static upstream. We spun up an example gRPC authentication service that uses a simple header for authentication. We then created an `AuthConfig` and configured it to use Passthrough Auth, pointing it to the IP of our example gRPC service. In doing so, we instructed gloo to pass through requests from the external authentication server to the grpc authentication service provided by the user.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
```yaml
2+
apiVersion: gateway.solo.io/v1
3+
kind: VirtualService
4+
metadata:
5+
name: grpc-auth-tutorial
6+
namespace: gloo-system
7+
spec:
8+
virtualHost:
9+
domains:
10+
- 'foo-grpc'
11+
routes:
12+
- matchers:
13+
- prefix: /
14+
routeAction:
15+
single:
16+
upstream:
17+
name: json-upstream
18+
namespace: gloo-system
19+
options:
20+
autoHostRewrite: true
21+
```

docs/content/guides/security/auth/extauth/passthrough_auth/http/_index.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ EOF
7676
Now let's configure Gloo Gateway to route requests to the upstream we just created. To do that, we define a simple Virtual
7777
Service to match all requests that:
7878

79-
- contain a `Host` header with value `foo` and
79+
- contain a `Host` header with value `foo-http` and
8080
- have a path that starts with `/` (this will match all requests).
8181

8282
Apply the following virtual service:
83-
{{< readfile file="guides/security/auth/extauth/basic_auth/test-no-auth-vs.yaml" markdown="true">}}
83+
{{< readfile file="guides/security/auth/extauth/passthrough_auth/http/test-no-auth-vs.yaml" markdown="true">}}
8484

8585
Let's send a request that matches the above route to the gateway proxy and make sure it works:
8686

8787
```shell
88-
curl -H "Host: foo" $(glooctl proxy url)/posts/1
88+
curl -H "Host: foo-http" $(glooctl proxy url)/posts/1
8989
```
9090

9191
The above command should produce the following output:
@@ -111,14 +111,14 @@ kubectl apply -f - <<EOF
111111
apiVersion: enterprise.gloo.solo.io/v1
112112
kind: AuthConfig
113113
metadata:
114-
name: passthrough-auth
114+
name: http-passthrough-auth
115115
namespace: gloo-system
116116
spec:
117117
configs:
118118
- passThroughAuth:
119119
http:
120120
# Url of the http auth server to use for auth
121-
url: http://example-http-auth-service.default.svc.cluster.local:9001
121+
url: http://example-http-auth-service.default.svc.cluster.local:9001/auth
122122
# Set a connection timeout to external service, default is 5 seconds
123123
connectionTimeout: 3s
124124
EOF
@@ -136,12 +136,12 @@ kubectl apply -f - <<EOF
136136
apiVersion: gateway.solo.io/v1
137137
kind: VirtualService
138138
metadata:
139-
name: auth-tutorial
139+
name: http-auth-tutorial
140140
namespace: gloo-system
141141
spec:
142142
virtualHost:
143143
domains:
144-
- 'foo'
144+
- 'foo-http'
145145
routes:
146146
- matchers:
147147
- prefix: /
@@ -151,11 +151,11 @@ spec:
151151
name: json-upstream
152152
namespace: gloo-system
153153
options:
154-
autoHostRewrite: true
154+
autoHostRewrite: true
155155
options:
156156
extauth:
157157
configRef:
158-
name: passthrough-auth
158+
name: http-passthrough-auth
159159
namespace: gloo-system
160160
EOF
161161
{{< /highlight >}}
@@ -189,7 +189,7 @@ If the auth config has been received successfully, you should see the log line:
189189
The virtual service that we have created should now be secured using our external authentication service. To test this, we can try our original command, and the request should not be allowed through because of missing authentication.
190190

191191
```shell
192-
curl -v -H "Host: foo" $(glooctl proxy url)/posts/1
192+
curl -v -H "Host: foo-http" $(glooctl proxy url)/posts/1
193193
```
194194

195195
In fact, if we check the logs of our sample http auth service, we see the following message:
@@ -205,7 +205,7 @@ kubectl apply -f - <<EOF
205205
apiVersion: enterprise.gloo.solo.io/v1
206206
kind: AuthConfig
207207
metadata:
208-
name: passthrough-auth
208+
name: http-passthrough-auth
209209
namespace: gloo-system
210210
spec:
211211
configs:
@@ -226,7 +226,7 @@ The sample Http authentication service has been implemented such that any reques
226226
passthrough auth to use the `/auth` path with the http auth server and to passthrough `Authorization` header. We can now add this header to our curl request as follows:
227227

228228
```shell
229-
curl -H "Host: foo" -H "authorization: authorize me" $(glooctl proxy url)/posts/1
229+
curl -H "Host: foo-http" -H "authorization: authorize me" $(glooctl proxy url)/posts/1
230230
```
231231

232232
The request should now be authorized!
@@ -239,7 +239,7 @@ For more information about configuration options, see the [API docs]({{< version
239239
apiVersion: enterprise.gloo.solo.io/v1
240240
kind: AuthConfig
241241
metadata:
242-
name: passthrough-auth
242+
name: http-passthrough-auth
243243
namespace: gloo-system
244244
spec:
245245
configs:
@@ -248,7 +248,7 @@ spec:
248248
# Url of the http auth server to use for auth
249249
# This can include path, and can also use https.
250250
# In order to use a https passthrough server, provide the cert in the HTTPS_PASSTHROUGH_CA_CERT environment variable to the ext-auth-service pod as a base64-encoded string.
251-
url: http://example-http-auth-service.default.svc.cluster.local:9001
251+
url: http://example-http-auth-service.default.svc.cluster.local:9001/auth
252252
# Set a connection timeout to external service, default is 5 seconds
253253
connectionTimeout: 3s
254254
# These options will modify the request going to the passthrough auth server
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
```yaml
2+
apiVersion: gateway.solo.io/v1
3+
kind: VirtualService
4+
metadata:
5+
name: http-auth-tutorial
6+
namespace: gloo-system
7+
spec:
8+
virtualHost:
9+
domains:
10+
- 'foo-http'
11+
routes:
12+
- matchers:
13+
- prefix: /
14+
routeAction:
15+
single:
16+
upstream:
17+
name: json-upstream
18+
namespace: gloo-system
19+
options:
20+
autoHostRewrite: true
21+
```

docs/content/reference/api/github.com/solo-io/gloo/projects/gloo/api/v1/enterprise/options/extauth/v1/extauth.proto.sk.md

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# GRPC Passthrough Auth Server
2+
3+
This server's `/auth` endpoint will return a 200 if the `authorization: authorize me` header is set, and a 403 otherwise
4+
5+
If the `REQUEST_LOGGING` environment variable is set the full request will be written to the logs
6+
7+
Build the `quay.io/solo-io/passthrough-grpc-service-example` image by running `make docker-local` from this directory.
+17-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
11
module github.com/envoyproxy/envoy/examples/ext_authz/auth/grpc-service
22

3-
go 1.14
3+
go 1.24
44

55
require (
6-
github.com/envoyproxy/go-control-plane v0.9.8
7-
github.com/golang/protobuf v1.4.2
8-
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
9-
google.golang.org/grpc v1.27.0
6+
github.com/envoyproxy/go-control-plane/envoy v1.32.3
7+
github.com/golang/protobuf v1.5.4
8+
github.com/solo-io/gloo v1.18.10
9+
google.golang.org/genproto v0.0.0-20250224174004-546df14abb99
10+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250219182151-9fdb1cabc7b2
11+
google.golang.org/grpc v1.70.0
12+
)
13+
14+
require (
15+
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 // indirect
16+
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
17+
github.com/planetscale/vtprotobuf v0.6.1-0.20240409071808-615f978279ca // indirect
18+
golang.org/x/net v0.35.0 // indirect
19+
golang.org/x/sys v0.30.0 // indirect
20+
golang.org/x/text v0.22.0 // indirect
21+
google.golang.org/protobuf v1.36.5 // indirect
1022
)

0 commit comments

Comments
 (0)