Commit 4098db8
committed
Fix owner user realm check for API key authentication (elastic#84325)
API Key can run-as since elastic#79809. There are places in the code where we
assume API key cannot run-as. Most of them are corrected in elastic#81564.
But there are still a few things got missed. This PR fixes the methods
for checking owner user realm for API key.
This means, when API Keys "running-as" (impersonating other users),
we do not expose the authenticating key ID and name to the end-user
such as the Authenticate API and the SetSecurityUseringest processor.
Only the effective user is revealed, just like in the regular case of a realm
user run as. For audit logging, the key's ID and name are not exposed
either. But this is mainly because there are no existing fields suitable for
these information. We do intend to add them later (elastic#84394) because
auditing logging is to consumed by system admin instead of end-users.
Note the resource sharing check (canAccessResourcesOf) also needs to be
fixed, this will be handled by elastic#842771 parent 615c3cd commit 4098db8
File tree
7 files changed
+152
-40
lines changed- x-pack/plugin
- core/src
- main/java/org/elasticsearch/xpack/core/security/authc
- test/java/org/elasticsearch/xpack/core/security/authc
- security/src
- main/java/org/elasticsearch/xpack/security
- audit/logfile
- authc
- ingest
- test/java/org/elasticsearch/xpack/security
- audit/logfile
- authc
7 files changed
+152
-40
lines changedLines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| |||
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
24 | 31 | | |
25 | 32 | | |
26 | 33 | | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| 40 | + | |
32 | 41 | | |
| 42 | + | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
| |||
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
| 51 | + | |
| 52 | + | |
41 | 53 | | |
| 54 | + | |
42 | 55 | | |
43 | 56 | | |
44 | 57 | | |
| |||
168 | 181 | | |
169 | 182 | | |
170 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
171 | 219 | | |
172 | 220 | | |
173 | 221 | | |
| |||
243 | 291 | | |
244 | 292 | | |
245 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
246 | 299 | | |
247 | 300 | | |
248 | 301 | | |
| |||
304 | 357 | | |
305 | 358 | | |
306 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
307 | 376 | | |
308 | 377 | | |
309 | 378 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1470 | 1470 | | |
1471 | 1471 | | |
1472 | 1472 | | |
1473 | | - | |
| 1473 | + | |
1474 | 1474 | | |
1475 | 1475 | | |
1476 | 1476 | | |
1477 | 1477 | | |
1478 | 1478 | | |
1479 | | - | |
| 1479 | + | |
1480 | 1480 | | |
1481 | 1481 | | |
1482 | 1482 | | |
| |||
1485 | 1485 | | |
1486 | 1486 | | |
1487 | 1487 | | |
| 1488 | + | |
| 1489 | + | |
1488 | 1490 | | |
| 1491 | + | |
1489 | 1492 | | |
1490 | 1493 | | |
1491 | 1494 | | |
1492 | 1495 | | |
| 1496 | + | |
1493 | 1497 | | |
1494 | 1498 | | |
1495 | 1499 | | |
| |||
Lines changed: 6 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1335 | 1335 | | |
1336 | 1336 | | |
1337 | 1337 | | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
| 1338 | + | |
| 1339 | + | |
1341 | 1340 | | |
1342 | 1341 | | |
1343 | 1342 | | |
1344 | 1343 | | |
1345 | 1344 | | |
1346 | | - | |
| 1345 | + | |
1347 | 1346 | | |
1348 | 1347 | | |
1349 | 1348 | | |
1350 | 1349 | | |
1351 | 1350 | | |
1352 | 1351 | | |
1353 | 1352 | | |
1354 | | - | |
1355 | | - | |
1356 | | - | |
| 1353 | + | |
| 1354 | + | |
1357 | 1355 | | |
1358 | 1356 | | |
1359 | 1357 | | |
1360 | 1358 | | |
1361 | 1359 | | |
1362 | | - | |
| 1360 | + | |
1363 | 1361 | | |
1364 | 1362 | | |
1365 | 1363 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
0 commit comments