Skip to content

Commit 8e51fbc

Browse files
committed
Added docs for authentication
1 parent 8ddd99b commit 8e51fbc

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: HTTP
3+
pcx_content_type: concept
4+
sidebar:
5+
order: 1
6+
head:
7+
- tag: title
8+
content: HTTP
9+
---
10+
11+
import { Render, PackageManagers } from "~/components";
12+
13+
You can send data to your Pipeline via HTTP. By default, HTTP is enabled on all Pipelines. When you create a Pipeline, it will generate an HTTP endpoint †hat you can make POST requests to.
14+
15+
```sh
16+
$ npx wrangler pipelines create [PIPELINE-NAME] --r2 [R2-BUCKET-NAME] --access-key-id [ACCESS-KEY-ID] --secret-access-key [SECRET-ACCESS-KEY]
17+
18+
🌀 Creating pipeline named "[PIPELINE-NAME]"
19+
✅ Successfully created pipeline [PIPELINE-NAME] with ID [PIPELINE-ID]
20+
21+
You can now send data to your pipeline with:
22+
curl "https://<PIPELINE-ID>.pipelines.cloudflare.com/" -d '[{ ...JSON_DATA... }]'
23+
```
24+
25+
## Turning HTTP off
26+
By default, ingestion via HTTP is turned on for all Pipelines. You can turn it off by setting `--http false` when creating or updating a Pipeline.
27+
28+
```sh
29+
$ npx wrangler pipelines create [PIPELINE-NAME] --r2 [R2-BUCKET-NAME] --access-key-id [ACCESS-KEY-ID] --secret-access-key [SECRET-ACCESS-KEY] --http false
30+
```
31+
32+
Ingestion URLs are tied to your Pipeline ID. Turning HTTP off, and then turning it back on, will not change the URL.
33+
34+
## Authentication
35+
You can secure your HTTP ingestion endpoint using Cloudflare API tokens. By default, authentication is turned off. To enable authentication, use `--authentication true` while creating or updating a Pipeline.
36+
37+
```
38+
$ npx wrangler pipelines create [PIPELINE-NAME] --r2 [R2-BUCKET-NAME] --access-key-id [ACCESS-KEY-ID] --secret-access-key [SECRET-ACCESS-KEY] --authentication true
39+
```
40+
41+
Once authentication is turned on, you will need to include a Cloudflare API token in your request headers.
42+
43+
### Get API token
44+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
45+
2. Navigate to your [API Keys](https://dash.cloudflare.com/profile/api-tokens)
46+
3. Select *Create Token*
47+
4. Choose the template for Workers Pipelines. Click on *continue to summary*, and finally on *create token*. Make sure to copy the API token, and save it securely.
48+
49+
### Making authenticated requests
50+
Include the API token you created in the previous step in the headers for your request:
51+
52+
```sh
53+
curl https://<PIPELINE-ID>.pipelines.cloudflare.com
54+
-H "Content-Type: application/json" \
55+
-H "Authorization: Bearer ${API_TOKEN}" \
56+
-d '[
57+
{"key1": "value1", "key2": "value2"},
58+
{"key1": "value3", "key2": "value4"}
59+
]'
60+
```

src/content/docs/pipelines/sources/worker-bindings.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: Worker Bindings
33
pcx_content_type: concept
44
sidebar:
5-
order: 1
5+
order: 2
66
head:
77
- tag: title
88
content: Worker Bindings
99
---
1010

11-
import { Render, PackageManagers } from "~/components"
11+
import { Render, PackageManagers } from "~/components";
1212

1313
You can send records to your Pipeline directly from a [Cloudflare Worker](workers/). To do so, you need to:
1414
1. Create a Worker
@@ -17,7 +17,7 @@ You can send records to your Pipeline directly from a [Cloudflare Worker](worker
1717
4. Write your Worker, to send records to your Pipeline
1818

1919
## 1. Create a Worker
20-
Create a Cloudflare Worker if you don't already have one. This Worker will send records to your Pipeline.
20+
Create a Cloudflare Worker if you don't alreadyåhave one. This Worker will send records to your Pipeline.
2121

2222
To create a Worker, run:
2323

0 commit comments

Comments
 (0)