This repository was archived by the owner on Oct 19, 2026. It is now read-only.
Repository navigation
Commit a467a25
authored
Fix identity extraction in cedar_guard middleware & correct revoke_bot_token OpenAPI docs (#2028)
* #1999: rebase
Signed-off-by: Hongze Gao <15101764808@163.com>
* - Export bot_token_dto in jupiter model so BotTokenInfo is reachable
- BotsStorage: add get_bot_by_id() for bot existence checks
- BotsStorage: use update_many() in revoke_bot_tokens_by_bot to avoid N+1
- BotsStorage: validate HMAC secret (non-empty, min 32 chars) in load_bot_token_hmac_key
- BotsStorage: use DateTimeWithTimeZone for expiry comparison in find_bot_by_token
- AuditStorage: set created_at with DateTimeWithTimeZone (Utc::now().into())
- bot_router: ensure bot exists before create/list/revoke; return 404 when missing
- bot_router: validate expires_in range (1..=10y) to avoid overflow/panic
- tests: add audit_storage to AppService in test_storage()
Signed-off-by: Hongze Gao <15101764808@163.com>
* #1999: fix identity extraction in cedar_guard middleware and revoke_bot_token 404 OpenAPI docs
- Use req.extract() to resolve LoginUser/BotIdentity instead of direct extensions access
- Fix missing Bot/Human context and incorrect "reader" fallback
- Update 404 description to "Bot not found"
- Align docs with idempotent implementation
Signed-off-by: Hongze Gao <15101764808@163.com>
* #1999: remove duplicate bot token helpers and module export
- remove duplicated in
- deduplicate bot token HMAC helpers in to fix E0428
- short-circuit auth extraction in :
try first, then only if needed
Signed-off-by: Hongze Gao <15101764808@163.com>
* #1999: use stateful axum extractors in cedar guard middleware
- replace state-less request extraction in with
for both
and
- fix incorrect import by removing and
importing instead
- keep short-circuit principal resolution: try bot identity first,
then attempt login user only when bot extraction fails
Signed-off-by: Hongze Gao <15101764808@163.com>
* #1999: use request parts API for stateful identity extraction in cedar_guard
- replace invalid usage with
and extract identities from
- run first,
then fall back to
- preserve middleware flow by reconstructing the request with
before calling
Signed-off-by: Hongze Gao <15101764808@163.com>
* #1999: satisfy clippy by matching extractor results directly
- replace + with direct
matching in
- keep principal resolution order unchanged:
first, then , then fallback
Signed-off-by: Hongze Gao <15101764808@163.com>
---------
Signed-off-by: Hongze Gao <15101764808@163.com>1 parent 94a1608 commit a467a25
2 files changed
Lines changed: 13 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
| 141 | + | |
143 | 142 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
172 | 174 | | |
173 | 175 | | |
174 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
| 317 | + | |
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| |||
0 commit comments