Skip to content

Commit 6082e0c

Browse files
rhaferScharfViktor
andauthored
fix: Show username in unprivileged search results (#2104)
* fix: Show username in unprivileged search results `onPremisesSamAccountName` is a mandatory attribute according to the spec. There's no harm in returning it in the search results also for unprivileged users. Fixes: #144 * adapt tests * adapt tests * adapt tests --------- Co-authored-by: Viktor Scharf <v.scharf@opencloud.eu>
1 parent 0b6de8e commit 6082e0c

4 files changed

Lines changed: 47 additions & 9 deletions

File tree

services/graph/pkg/service/v0/users.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,11 @@ func (g Graph) GetUsers(w http.ResponseWriter, r *http.Request) {
306306
finalUsers := make([]*libregraph.User, len(users))
307307
for i, u := range users {
308308
finalUsers[i] = &libregraph.User{
309-
Id: u.Id,
310-
DisplayName: u.DisplayName,
311-
UserType: u.UserType,
312-
Identities: u.Identities,
309+
Id: u.Id,
310+
DisplayName: u.DisplayName,
311+
UserType: u.UserType,
312+
Identities: u.Identities,
313+
OnPremisesSamAccountName: u.OnPremisesSamAccountName,
313314
}
314315

315316
if g.config.API.ShowUserEmailInResults {

tests/acceptance/features/apiGraphUserGroup/getUser.feature

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,7 @@ Feature: get users
13511351
"required": [
13521352
"displayName",
13531353
"id",
1354+
"onPremisesSamAccountName",
13541355
"userType"
13551356
],
13561357
"properties": {
@@ -1362,6 +1363,10 @@ Feature: get users
13621363
"type": "string",
13631364
"pattern": "^%user_id_pattern%$"
13641365
},
1366+
"onPremisesSamAccountName": {
1367+
"type": "string",
1368+
"const": "Alice"
1369+
},
13651370
"userType": {
13661371
"type": "string",
13671372
"const": "Member"
@@ -1456,6 +1461,7 @@ Feature: get users
14561461
"required": [
14571462
"displayName",
14581463
"id",
1464+
"onPremisesSamAccountName",
14591465
"userType"
14601466
],
14611467
"properties": {
@@ -1467,6 +1473,10 @@ Feature: get users
14671473
"type": "string",
14681474
"pattern": "^%user_id_pattern%$"
14691475
},
1476+
"onPremisesSamAccountName": {
1477+
"type": "string",
1478+
"const": "Alice"
1479+
},
14701480
"userType": {
14711481
"type": "string",
14721482
"const": "Member"
@@ -1501,6 +1511,7 @@ Feature: get users
15011511
"required": [
15021512
"displayName",
15031513
"id",
1514+
"onPremisesSamAccountName",
15041515
"userType"
15051516
],
15061517
"properties": {
@@ -1512,6 +1523,10 @@ Feature: get users
15121523
"type": "string",
15131524
"pattern": "^%user_id_pattern%$"
15141525
},
1526+
"onPremisesSamAccountName": {
1527+
"type": "string",
1528+
"const": "Alice"
1529+
},
15151530
"userType": {
15161531
"type": "string",
15171532
"const": "Member"
@@ -1530,7 +1545,6 @@ Feature: get users
15301545
| displayName | Alice Hansen |
15311546
| email | another-alice@example.org |
15321547
| password | containsCharacters(*:!;_+-&) |
1533-
And the administrator has assigned the role "Admin" to user "Alice" using the Graph API
15341548
When user "Brian" searches for user "alice" using Graph API
15351549
Then the HTTP status code should be "200"
15361550
And the JSON data of the search response should not contain users email
@@ -1554,6 +1568,7 @@ Feature: get users
15541568
"required": [
15551569
"displayName",
15561570
"id",
1571+
"onPremisesSamAccountName",
15571572
"userType"
15581573
],
15591574
"properties": {
@@ -1565,6 +1580,10 @@ Feature: get users
15651580
"type": "string",
15661581
"pattern": "^%user_id_pattern%$"
15671582
},
1583+
"onPremisesSamAccountName": {
1584+
"type": "string",
1585+
"const": "Alice"
1586+
},
15681587
"userType": {
15691588
"type": "string",
15701589
"const": "Member"
@@ -1576,6 +1595,7 @@ Feature: get users
15761595
"required": [
15771596
"displayName",
15781597
"id",
1598+
"onPremisesSamAccountName",
15791599
"userType"
15801600
],
15811601
"properties": {
@@ -1587,11 +1607,13 @@ Feature: get users
15871607
"type": "string",
15881608
"pattern": "^%user_id_pattern%$"
15891609
},
1610+
"onPremisesSamAccountName": {
1611+
"type": "string",
1612+
"const": "another-alice"
1613+
},
15901614
"userType": {
15911615
"type": "string",
1592-
"const": [
1593-
"Admin"
1594-
]
1616+
"const": "Member"
15951617
}
15961618
}
15971619
}

tests/acceptance/features/apiGraphUserGroup/searchUserIncludingEmail.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ Feature: edit/search user including email
274274
"required": [
275275
"displayName",
276276
"id",
277+
"onPremisesSamAccountName",
277278
"mail",
278279
"userType"
279280
],
@@ -285,6 +286,9 @@ Feature: edit/search user including email
285286
"type": "string",
286287
"pattern": "^%user_id_pattern%$"
287288
},
289+
"onPremisesSamAccountName": {
290+
"const": "Alice"
291+
},
288292
"mail": {
289293
"const": "alice@example.org"
290294
},
@@ -366,6 +370,7 @@ Feature: edit/search user including email
366370
"required": [
367371
"displayName",
368372
"id",
373+
"onPremisesSamAccountName",
369374
"mail",
370375
"userType"
371376
],
@@ -377,6 +382,9 @@ Feature: edit/search user including email
377382
"type": "string",
378383
"pattern": "^%user_id_pattern%$"
379384
},
385+
"onPremisesSamAccountName": {
386+
"const": "Alice"
387+
},
380388
"mail": {
381389
"const": "alice@example.org"
382390
},
@@ -417,6 +425,7 @@ Feature: edit/search user including email
417425
"required": [
418426
"displayName",
419427
"id",
428+
"onPremisesSamAccountName",
420429
"mail",
421430
"userType"
422431
],
@@ -428,6 +437,9 @@ Feature: edit/search user including email
428437
"type": "string",
429438
"pattern": "^%user_id_pattern%$"
430439
},
440+
"onPremisesSamAccountName": {
441+
"const": "Alice"
442+
},
431443
"mail": {
432444
"const": "alice@example.org"
433445
},
@@ -452,6 +464,9 @@ Feature: edit/search user including email
452464
"type": "string",
453465
"pattern": "^%user_id_pattern%$"
454466
},
467+
"onPremisesSamAccountName": {
468+
"const": "another-alice"
469+
},
455470
"mail": {
456471
"const": "another-alice@example.org"
457472
},

tests/acceptance/features/apiTenancy/mutltiTenancy.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Feature: Multi-tenancy
4545
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
4646
},
4747
"onPremisesSamAccountName": {
48-
"const": ""
48+
"const": "alice"
4949
},
5050
"userType": {
5151
"const": "Member"

0 commit comments

Comments
 (0)