Commit 787f261
committed
Fix NPE on getUserKeys when accessed via the integration API port
Requests sent to the integration API port (integration.api.port, 8096 by
default) are not signature-checked and run as the system user. Clients such
as the cs CLI still send an apikey and signature parameter, so
getAccessingApiKey() picked up an API key that was never used to authenticate
the request. Looking that key up returned null and getUserKeys, listUserKeys,
registerUserKeys and listApis failed with a NullPointerException.
Only treat the request's API key as the accessing key pair when it maps to a
key pair owned by the calling user. For the system user (integration API
port) a mismatching key is ignored and the caller's role permissions apply,
as for session-authenticated requests. For any other caller a mismatching
key is rejected with a PermissionDeniedException, since the request cannot
have been authenticated through it. Also guard the key pair lookups against
null so an unknown key can no longer cause a NullPointerException.1 parent 036493f commit 787f261
2 files changed
Lines changed: 138 additions & 7 deletions
File tree
- server/src
- main/java/com/cloud/user
- test/java/com/cloud/user
Lines changed: 42 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3315 | 3315 | | |
3316 | 3316 | | |
3317 | 3317 | | |
3318 | | - | |
| 3318 | + | |
3319 | 3319 | | |
3320 | 3320 | | |
3321 | | - | |
3322 | | - | |
3323 | | - | |
3324 | | - | |
| 3321 | + | |
| 3322 | + | |
3325 | 3323 | | |
3326 | | - | |
| 3324 | + | |
| 3325 | + | |
3327 | 3326 | | |
3328 | 3327 | | |
3329 | 3328 | | |
| |||
3436 | 3435 | | |
3437 | 3436 | | |
3438 | 3437 | | |
| 3438 | + | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
3439 | 3442 | | |
3440 | 3443 | | |
3441 | 3444 | | |
| |||
3454 | 3457 | | |
3455 | 3458 | | |
3456 | 3459 | | |
3457 | | - | |
| 3460 | + | |
3458 | 3461 | | |
3459 | 3462 | | |
3460 | 3463 | | |
| |||
3467 | 3470 | | |
3468 | 3471 | | |
3469 | 3472 | | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
| 3498 | + | |
| 3499 | + | |
| 3500 | + | |
| 3501 | + | |
3470 | 3502 | | |
3471 | 3503 | | |
3472 | 3504 | | |
| |||
3727 | 3759 | | |
3728 | 3760 | | |
3729 | 3761 | | |
| 3762 | + | |
| 3763 | + | |
| 3764 | + | |
3730 | 3765 | | |
3731 | 3766 | | |
3732 | 3767 | | |
| |||
Lines changed: 96 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2289 | 2289 | | |
2290 | 2290 | | |
2291 | 2291 | | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
| 2377 | + | |
| 2378 | + | |
| 2379 | + | |
| 2380 | + | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
2292 | 2388 | | |
0 commit comments