Repository navigation
Commit db31e65
authored
[fix](auth) fix SHOW GRANTS FOR always showing RequireSan=NULL (apache#7733)
## Problem
`SHOW GRANTS FOR '<user>'@'%'` always displayed `RequireSan=NULL` even
when `REQUIRE SAN` was set and actively enforced. `SHOW ALL GRANTS`
showed the correct value.
Reported on: selectdb-4.1.0-c574af9014e, fra03 dev-doritos and iad03
abuse-prevention-platform.
## Root Cause
`Auth.getUserAuthInfo()` computed `requireSan` from the `UserIdentity`
passed in by the caller. For `SHOW GRANTS FOR <user>`, the SQL parser
constructs a **fresh** `UserIdentity` with only `user` and `host`
populated — the `san` field is never set. By contrast, `SHOW ALL GRANTS`
iterates directly over stored `User` objects whose `UserIdentity`
carries the persisted `san` value.
## Fix
In `getUserAuthInfo()`, look up the stored `User` via
`userManager.getUserByUserIdentity()` **before** computing `requireSan`,
and derive the value from the persisted `UserIdentity` instead of the
parameter. `UserIdentity.equals()` compares only `(user, host,
isDomain)`, so the lookup correctly matches the parser-created identity
to the stored record.
As a side effect, the redundant second `getUserByUserIdentity` call in
the non-LDAP branch is eliminated.
## Files Changed
- `fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java`
— fix in `getUserAuthInfo()`
-
`fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/CloudAuthTest.java`
— regression test `testShowGrantsForUserDisplaysRequireSan()`
## Test
Added `CloudAuthTest#testShowGrantsForUserDisplaysRequireSan()`: creates
a user with `REQUIRE SAN`, then calls `SHOW GRANTS FOR` with a
parser-simulated `UserIdentity` (no `san` set) and asserts the
`RequireSan` column returns the correct SAN value instead of `\N`.1 parent fcb970e commit db31e65
2 files changed
Lines changed: 44 additions & 6 deletions
File tree
- fe/fe-core/src
- main/java/org/apache/doris/mysql/privilege
- test/java/org/apache/doris/mysql/privilege
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1333 | 1333 | | |
1334 | 1334 | | |
1335 | 1335 | | |
1336 | | - | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
1337 | 1343 | | |
1338 | | - | |
| 1344 | + | |
1339 | 1345 | | |
1340 | 1346 | | |
1341 | 1347 | | |
| |||
1348 | 1354 | | |
1349 | 1355 | | |
1350 | 1356 | | |
1351 | | - | |
1352 | | - | |
| 1357 | + | |
1353 | 1358 | | |
1354 | 1359 | | |
1355 | 1360 | | |
1356 | 1361 | | |
1357 | 1362 | | |
1358 | 1363 | | |
1359 | | - | |
| 1364 | + | |
1360 | 1365 | | |
1361 | | - | |
| 1366 | + | |
1362 | 1367 | | |
1363 | 1368 | | |
1364 | 1369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
620 | 622 | | |
621 | 623 | | |
622 | 624 | | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
623 | 656 | | |
0 commit comments