Skip to content

Commit ce2b322

Browse files
ranbelGregBrimble
authored andcommitted
[ZT] Use Access service token in one header (#22035)
* send service token in one header * clarify PUT request body
1 parent 012219c commit ce2b322

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/content/docs/cloudflare-one/identity/service-tokens.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 6
66
---
77

8-
import { AvailableNotifications, Render } from "~/components";
8+
import { AvailableNotifications, Render, APIRequest } from "~/components";
99

1010
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.
1111

@@ -35,6 +35,37 @@ curl -H "CF-Access-Client-Id: <CLIENT_ID>" -H "CF-Access-Client-Secret: <CLIENT_
3535

3636
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.
3737

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+
3869
### Subsequent requests
3970

4071
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

Comments
 (0)