Skip to content

Commit 0c3787e

Browse files
committed
up
1 parent cedab8a commit 0c3787e

1 file changed

Lines changed: 154 additions & 0 deletions

File tree

docs/AUTHENTICATION.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@ return [
115115

116116
#### Method 1: Header (Recommended)
117117

118+
**Postman:**
119+
```
120+
GET http://localhost/api.php?action=tables
121+
122+
Headers:
123+
X-API-Key: changeme123
124+
125+
Steps:
126+
1. Create new request (GET)
127+
2. URL: http://localhost/api.php?action=tables
128+
3. Go to "Headers" tab
129+
4. Add header:
130+
- Key: X-API-Key
131+
- Value: changeme123
132+
5. Click "Send"
133+
```
134+
135+
**HTTPie:**
136+
```bash
137+
http GET http://localhost/api.php action==tables X-API-Key:changeme123
138+
139+
# Or with explicit header syntax:
140+
http http://localhost/api.php action==tables "X-API-Key: changeme123"
141+
```
142+
118143
**cURL:**
119144
```bash
120145
curl -H "X-API-Key: changeme123" \
@@ -163,6 +188,30 @@ http://localhost/api.php?action=tables&api_key=changeme123
163188

164189
⚠️ **Warning:** Query parameters are logged in server access logs. Use headers for production.
165190

191+
**Postman:**
192+
```
193+
GET http://localhost/api.php?action=tables&api_key=changeme123
194+
195+
Steps:
196+
1. Create new request (GET)
197+
2. URL: http://localhost/api.php
198+
3. Go to "Params" tab
199+
4. Add parameters:
200+
- action: tables
201+
- api_key: changeme123
202+
5. Click "Send"
203+
```
204+
205+
**HTTPie:**
206+
```bash
207+
http GET http://localhost/api.php action==tables api_key==changeme123
208+
```
209+
210+
**cURL:**
211+
```bash
212+
curl "http://localhost/api.php?action=tables&api_key=changeme123"
213+
```
214+
166215
**JavaScript:**
167216
```javascript
168217
fetch('http://localhost/api.php?action=tables&api_key=changeme123')
@@ -232,6 +281,37 @@ fetch('http://localhost/api.php?action=tables&api_key=changeme123')
232281

233282
#### Method 1: Authorization Header
234283

284+
**Postman:**
285+
```
286+
GET http://localhost/api.php?action=tables
287+
288+
Authorization:
289+
Type: Basic Auth
290+
Username: admin
291+
Password: secret
292+
293+
Steps:
294+
1. Create new request (GET)
295+
2. URL: http://localhost/api.php?action=tables
296+
3. Go to "Authorization" tab
297+
4. Type: Select "Basic Auth" from dropdown
298+
5. Username: admin
299+
6. Password: secret
300+
7. Click "Send"
301+
302+
Postman automatically encodes credentials as Base64 and adds header:
303+
Authorization: Basic YWRtaW46c2VjcmV0
304+
```
305+
306+
**HTTPie:**
307+
```bash
308+
# Method 1: Simple syntax (HTTPie handles Basic Auth automatically)
309+
http -a admin:secret GET http://localhost/api.php action==tables
310+
311+
# Method 2: Explicit header (manual Base64 encoding)
312+
http GET http://localhost/api.php action==tables "Authorization: Basic YWRtaW46c2VjcmV0"
313+
```
314+
235315
**cURL:**
236316
```bash
237317
curl -u admin:secret \
@@ -1140,6 +1220,78 @@ php -r "
11401220

11411221
## Summary - Quick Reference
11421222

1223+
### Postman Quick Setup Guide
1224+
1225+
#### 1. API Key Authentication
1226+
```
1227+
Request Type: GET
1228+
URL: http://localhost/api.php?action=tables
1229+
1230+
Option A - Header (Recommended):
1231+
├── Headers tab
1232+
└── Add: X-API-Key = changeme123
1233+
1234+
Option B - Query Parameter:
1235+
├── Params tab
1236+
└── Add: api_key = changeme123
1237+
```
1238+
1239+
#### 2. Basic Authentication
1240+
```
1241+
Request Type: GET
1242+
URL: http://localhost/api.php?action=tables
1243+
1244+
Authorization tab:
1245+
├── Type: Basic Auth
1246+
├── Username: admin
1247+
└── Password: secret
1248+
```
1249+
1250+
#### 3. JWT Authentication
1251+
```
1252+
Step 1 - Login:
1253+
Request Type: POST
1254+
URL: http://localhost/api.php?action=login
1255+
1256+
Body → x-www-form-urlencoded:
1257+
├── username: john
1258+
└── password: SecurePass123!
1259+
1260+
Response: Copy the "token" value
1261+
1262+
Step 2 - Use Token:
1263+
Request Type: GET
1264+
URL: http://localhost/api.php?action=tables
1265+
1266+
Headers tab:
1267+
└── Add: Authorization = Bearer eyJ0eXAiOiJKV1Qi...
1268+
```
1269+
1270+
---
1271+
1272+
### HTTPie Quick Syntax Guide
1273+
1274+
```bash
1275+
# API Key (Header)
1276+
http GET http://localhost/api.php action==tables X-API-Key:changeme123
1277+
1278+
# API Key (Query Parameter)
1279+
http GET http://localhost/api.php action==tables api_key==changeme123
1280+
1281+
# Basic Auth
1282+
http -a admin:secret GET http://localhost/api.php action==tables
1283+
1284+
# JWT Login
1285+
http POST http://localhost/api.php action==login username=john password=SecurePass123!
1286+
1287+
# JWT Request (after login)
1288+
http GET http://localhost/api.php action==tables "Authorization: Bearer TOKEN_HERE"
1289+
```
1290+
1291+
---
1292+
1293+
### Method Comparison Table
1294+
11431295
| Feature | API Key | Basic Auth | JWT |
11441296
|---------|---------|------------|-----|
11451297
| **Config Value** | `'apikey'` | `'basic'` | `'jwt'` |
@@ -1152,6 +1304,8 @@ php -r "
11521304
| **Performance** | ⚡ Fast | ⚡ Fast | ⚡⚡⚡ Very Fast |
11531305
| **Security** | 🔒 Medium | 🔒 Medium | 🔒🔒 High |
11541306
| **User Tracking** | ❌ (shared key) |||
1307+
| **Postman Setup** | Headers or Params | Authorization tab | Headers (after login) |
1308+
| **HTTPie Syntax** | `X-API-Key:value` | `-a user:pass` | `"Authorization: Bearer ..."` |
11551309

11561310
---
11571311

0 commit comments

Comments
 (0)