Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 20923bb

Browse files
committedApr 23, 2024
adds most of advanced routes guide
1 parent 1037b10 commit 20923bb

8 files changed

+91
-15
lines changed
 

‎content/docs/courses/zero-fundamentals/advanced-policies.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ If you're following these guides sequentially, your current policy only includes
5151
</TabItem>
5252
</Tabs>
5353
54-
This policy is a great first step to protecting your services. If you're using a workspace email address, you can immediately restrict access to allow only members of your organization. But you'll likely want to add more complex policies based on your use case.
54+
This policy is a great first step to protecting your services. If you're using a workspace email address, you can immediately restrict access to allow only members of your organization. But you'll likely want to add more complex policies that only grant access to a specific user or group of users.
5555
5656
With Pomerium Policy Language (PPL), you can build richer policies that apply to real-world use cases. Let's cover a few example "real-world" policies below that would fall into the "advanced" category.
5757

‎content/docs/courses/zero-fundamentals/advanced-routes.mdx

+90-14
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Make sure you’ve completed the following guides:
1515

1616
- [**Build a Simple Route**](/docs/courses/zero-fundamentals/build-routes)
1717
- [**Build a Simple Policy**](/docs/courses/zero-fundamentals/build-policies)
18-
- [**Identity Verification with JWTs**](/docs/courses/zero-fundamentals/sing-sign-on)
18+
- [**Single Sign-on with JWTs**](/docs/courses/zero-fundamentals/single-sign-on)
1919
- [**Build Advanced Policies**](/docs/courses/zero-fundamentals/advanced-policies)
2020

2121
Each tutorial builds on the same configuration files. In this tutorial, you’ll build new routes with some of Pomerium’s route-level settings.
@@ -26,18 +26,18 @@ Each tutorial builds on the same configuration files. In this tutorial, you’ll
2626

2727
Pomerium provides route-level settings that allow you to customize how the Proxy service handles requests. More advanced configurations allow identity header pass-through, path and prefix rewrites, and request and response header modifications.
2828

29-
For the purposes of this tutorial, we will only review the following settings to give you an idea of how you can further configure your routes for your use case:
29+
For the purposes of this guide, we will only review select settings from the list below to give you an idea of how you can further configure routes for your use case:
3030

31-
- **Remove Request Headers**
32-
- **Host Rewrite Headers**
33-
- **Set Response Headers**
34-
- **Redirects**
31+
- **Headers**
32+
- **Path Matching**
33+
- **Path Rewriting**
3534
- **Prefix & Prefix Rewrite**
35+
- **Redirects**
3636
- **Direct Response**
3737

3838
### Configure HTTPBin
3939

40-
To see how some of these settings work, we will configure Pomerium and Docker Compose to host an HTTPBin server. If you’re not familiar with [HTTPBin](https://httpbin.org/), it’s a call-and-response HTTP server you can use to test (you guessed it) HTTP requests and responses.
40+
To test these settings, we will configure Pomerium Zero and Docker Compose to host an HTTPBin server. If you’re not familiar with [HTTPBin](https://httpbin.org/), it’s a call-and-response HTTP server you can use to test (you guessed it) HTTP requests and responses.
4141

4242
Add the `httpbin` service to your Docker Compose file:
4343

@@ -48,7 +48,7 @@ httpbin:
4848
- 80:80
4949
```
5050
51-
Add the `httpbin` route in your Pomerium configuration file:
51+
Add the `httpbin` route in the Zero Console:
5252

5353
1. Create a new route
5454
1. Add **From** and **To** URLs
@@ -58,9 +58,9 @@ Save your route and apply your changeset.
5858

5959
## Test Headers settings
6060

61-
### Identity headers
61+
### Pass identity headers (per route)
6262

63-
[Pass Identity Headers](/docs/reference/routes/pass-identity-headers-per-route) is a route-level setting that forwards a signed JWT to the upstream application in a signed HTTP header. The HTTP header must use the (case insensitive) `x-pomerium-jwt-assertion` format. You configured this setting in the [previous guide](/docs/courses/zero-fundamentals/single-sign-on), but let's see how it looks as a request header.
63+
[Pass Identity Headers](/docs/reference/routes/pass-identity-headers-per-route) is a route-level setting that forwards the user's JWT to the upstream application in a signed HTTP header. The HTTP header must use the (case insensitive) `x-pomerium-jwt-assertion` format. You configured this setting in the [previous guide](/docs/courses/zero-fundamentals/single-sign-on), but let's see how it looks as a request header.
6464

6565
In the Zero Console:
6666

@@ -69,17 +69,93 @@ In the Zero Console:
6969
1. Apply the **Pass Identity Headers** setting
7070
1. Save your route and apply the changeset
7171

72-
Access the HTTPBin route and send a request:
72+
Access the HTTPBin route and send a request. To send a request, on the HTTPBin page:
7373

74+
1. Open the **Request inspection** dropdown menu
75+
1. In **GET /headers**, select **Try it out**
76+
1. Select **Execute** to send the request
7477

78+
In the **Response body** field, you'll see the JWT assertion header:
7579

76-
:::info
80+
![Inspecting the HTTP request headers in HTTPBin to view the JWT assertion header](./img/advanced-routes/jwt-assertion-header.png)
7781

78-
RESUME HERE
82+
:::info JWTs and SDKs
83+
84+
Read the following documentation to learn more about identity verification in Pomerium:
85+
86+
- [**Identity verification**](/docs/capabilities/getting-users-identity)
87+
- [**Manually verifying the JWT**](/docs/capabilities/getting-users-identity#manual-verification)
88+
89+
We also provide SDKs for JWT verification in the following languages:
90+
91+
- [**Go**](https://github.com/pomerium/sdk-go)
92+
- [**Node.js and Express**](https://github.com/pomerium/js-sdk/tree/main/examples/express)
93+
- [**JavaScript**](https://github.com/pomerium/js-sdk)
7994

8095
:::
8196

82-
The **Pass Identity Headers** and **JWT Claim Headers** settings both forward identity headers to an upstream application.
97+
### JWT Claim Headers
98+
99+
The pass identity headers setting can also forward _unsigned_ identity headers as additional [JWT Claim Headers](/docs/reference/jwt-claim-headers).
100+
101+
To add JWT claim headers in the Zero Console:
102+
103+
1. Select the **Settings** tab in the main sidebar
104+
1. In **Editing Cluster Settings**, select **Headers**
105+
1. In the **JWT Claim Headers** field, enter the values below:
106+
107+
| **KEY** | **VALUE** |
108+
| :--- | :--- |
109+
| `x-pomerium-claim-email` | `email` |
110+
| `x-pomerium-claim-user` | `user` |
111+
| `x-pomerium-claim-name` | `name` |
112+
113+
For example:
114+
115+
![Entering custom JWT claim headers in the Zero Console](./img/advanced-routes/jwt-claim-headers.png)
116+
117+
118+
After you save your changes, apply your changeset, and access your HTTPBin route, inspect the request. You'll see these additional, unsigned HTTP headers added to the response body:
119+
120+
![Reviewing the JWT claim headers added to the route](./img/advanced-routes/jwt-claims-response.png)
121+
122+
### Set and remove request headers
123+
124+
Now, configure [**Set Request Headers**](/docs/reference/routes/headers#set-request-headers) to add static custom HTTP headers to your request:
125+
126+
1. Go back to the HTTPBin headers settings
127+
1. In **Property Name**, enter `X-SET-REQUEST-HEADERS`
128+
1. In **Property Value**, enter `X-TEST-VALUE`
129+
130+
Next, configure [**Remove Request Headers**](/docs/reference/routes/headers#remove-request-headers) to remove two of the JWT claim headers you set in the previous section.
131+
132+
1. In the **Remove Request Headers** field, enter `X-POMERIUM-CLAIM-NAME` and `X-POMERIUM-CLAIM-USER`.
133+
134+
![Setting and removing HTTP request headers in the Zero Console](./img/advanced-routes/set-and-remove-request-headers.png)
135+
136+
Apply your changeset and test the request again. You'll notice that the set request header was added to the request, and the specified JWT claim headers were removed:
137+
138+
![Reviewing the response body in HTTPBin after setting and removing HTTP headers](./img/advanced-routes/set-and-remove-headers-response-body.png)
139+
140+
### Rewrite Host header to a literal value
141+
142+
You may need to modify the value of the Host header. For example, some servers may only accept Host headers with a value that matches the [Origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin) of the request. The [Host Rewrite](/docs/reference/routes/headers#2-host-rewrite) setting allows you to modify the Host header in the HTTP request to a literal value.
143+
144+
If you don't tamper with this setting, the value of the Host header will be the hostname of our upstream service: `"Host": "httpbin"`.
145+
146+
Now, go back to the **Headers** tab for the HTTPBin route. In the **Host Rewrite to Literal** field, enter your HTTPBin route.
147+
148+
For example, `httpbin.righteous-gemstone-1734.pomerium.app`
149+
150+
![Configuring Pomerium to rewrite the Host header to a literal value](./img/advanced-routes/host-rewrite-to-literal-value.png)
151+
152+
After applying your changeset, check the request headers in HTTPBin again. You'll notice Pomerium rewrites the Host header to the domain you entered in the Zero Console:
153+
154+
`"Host": "httpbin.righteous-gemstone-1734.pomerium.app"`
155+
156+
## Redirects and Direct Response
157+
158+
RESUME HERE
83159
84160
85161
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.