Commit 8558856
committed
fix: use real agent ID in challenge pages (first 8 chars for security)
Previously challenge pages showed random placeholder like "DEF-CJW5" instead of
the real agent ID. This was confusing and inconsistent with D-Agent-ID headers.
Changes:
- Added agentID field to ChallengeManager struct
- Added SetAgentID() method to set real agent ID from config
- Added GetAgentID() method to return first 8 chars (security)
- Updated all ChallengeTemplateData to use cm.GetAgentID()
- Added SetAgentID(agentID) call in main.go after config initialization
- Updated getShortAgentID() as fallback for tests
Security consideration:
- Only first 8 characters of agent ID are displayed (matches D-Agent-ID format)
- Full agent ID is never exposed in challenge pages
- Consistent with HTTP header format: GEO+First8Chars
Example:
- Real agent ID: "agent-a1b2c3d4-e5f6-7890-abcd-ef1234567890"
- Challenge page shows: "a1b2c3d4"
- HTTP header shows: "US+a1b2c3d4"
Logs: [ChallengeManager] Agent ID set for challenge pages: a1b2c3d41 parent 0254192 commit 8558856
2 files changed
+35
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | | - | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| |||
1520 | 1521 | | |
1521 | 1522 | | |
1522 | 1523 | | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
0 commit comments