Skip to content

Commit bc6afe2

Browse files
authored
Document Authentication
1 parent 88f0155 commit bc6afe2

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

docs/README.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,39 @@ LOAD httpserver;
3232
```
3333

3434
### 🔌 Usage
35-
Start the HTTP server providing the `host` and `port` parameters
35+
Start the HTTP server providing the `host`, `port` and `auth` parameters.<br>
36+
> If you want no authhentication, just pass an empty string.
37+
38+
#### Basic Auth
3639
```sql
37-
D SELECT httpserve_start('0.0.0.0',9999);
38-
┌─────────────────────────────────────┐
39-
│ httpserve_start('0.0.0.0', 9999) │
40-
varchar
41-
├─────────────────────────────────────┤
42-
│ HTTP server started on 0.0.0.0:9999
43-
└─────────────────────────────────────┘
40+
D SELECT httpserve_start('localhost', 9999, 'user:pass');
41+
42+
┌───────────────────────────────────────────────┐
43+
│ httpserve_start('0.0.0.0', 9999, 'user:pass') │
44+
varchar
45+
├───────────────────────────────────────────────┤
46+
│ HTTP server started on 0.0.0.0:9999
47+
└───────────────────────────────────────────────┘
4448
```
49+
```bash
50+
curl -X POST -d "SELECT 'hello', version()" "http://user:pass@localhost:9999/"
51+
```
52+
53+
#### Token Auth
54+
```sql
55+
SELECT httpserve_start('localhost', 9999, 'supersecretkey');
56+
57+
┌───────────────────────────────────────────────┐
58+
│ httpserve_start('0.0.0.0', 9999, 'secretkey') │
59+
varchar
60+
├───────────────────────────────────────────────┤
61+
│ HTTP server started on 0.0.0.0:9999
62+
└───────────────────────────────────────────────┘
63+
```
64+
```
65+
curl -X POST --header "X-API-Key: supersecretkey" -d "SELECT 'hello', version()" "http://localhost:9999/"
66+
```
67+
4568

4669
#### 👉 QUERY UI
4770
Browse to your endpoint and use the built-in quackplay interface _(experimental)_

0 commit comments

Comments
 (0)