|
5 | 5 | order: 6 |
6 | 6 | --- |
7 | 7 |
|
8 | | -import { AvailableNotifications, Render } from "~/components"; |
| 8 | +import { AvailableNotifications, Render, APIRequest } from "~/components"; |
9 | 9 |
|
10 | 10 | You can provide automated systems with service tokens to authenticate against your Zero Trust policies. Cloudflare Access will generate service tokens that consist of a Client ID and a Client Secret. Automated systems or applications can then use these values to reach an application protected by Access. |
11 | 11 |
|
@@ -35,6 +35,37 @@ curl -H "CF-Access-Client-Id: <CLIENT_ID>" -H "CF-Access-Client-Secret: <CLIENT_ |
35 | 35 |
|
36 | 36 | If the service token is valid, Access generates a JWT scoped to the application in the form of a [`CF_Authorization` cookie](/cloudflare-one/identity/authorization-cookie/). You can use this cookie to authenticate [subsequent requests](#subsequent-requests) to the application. |
37 | 37 |
|
| 38 | +#### Authenticate with a single header |
| 39 | + |
| 40 | +You can configure a self-hosted Access application to accept a service token in a single HTTP header, as an alternative to the `CF-Access-Client-Id` and `CF-Access-Client-Secret` pair of headers. This is useful for authenticating SaaS services that only support sending one custom header in a request (for example, the `Authorization` header). |
| 41 | + |
| 42 | +To authenticate using a single header: |
| 43 | + |
| 44 | +1. Get your existing Access application configuration: |
| 45 | + |
| 46 | + <APIRequest |
| 47 | + path="/accounts/{account_id}/access/apps/{app_id}" |
| 48 | + method="GET" |
| 49 | + /> |
| 50 | + |
| 51 | +2. Make a `PUT` request with the name of the header you want to use for service token authentication. To avoid overwriting your existing configuration, the `PUT` request body should contain all fields returned by the previous `GET` request. |
| 52 | + |
| 53 | + <APIRequest |
| 54 | + path="/accounts/{account_id}/access/apps/{app_id}" |
| 55 | + method="PUT" |
| 56 | + json={{ |
| 57 | + "domain": "app.example.com", |
| 58 | + "type": "self_hosted", |
| 59 | + "read_service_tokens_from_header": "Authorization" |
| 60 | + }} |
| 61 | + /> |
| 62 | + |
| 63 | +2. Add the header to any HTTP request. For example, |
| 64 | + |
| 65 | + ```sh |
| 66 | + curl -H "Authorization: {"CF-Access-Client-Id": "<CLIENT_ID>", "CF_Access-Client-Secret": "<CLIENT_SECRET>"}" https://app.example.com |
| 67 | + ``` |
| 68 | + |
38 | 69 | ### Subsequent requests |
39 | 70 |
|
40 | 71 | After you have [authenticated to the application](#initial-request) using the service token, add the resulting `CF_Authorization` cookie to the headers of all subsequent requests: |
|
0 commit comments