Skip to content

Commit 6785080

Browse files
Merge pull request #346 from silinternational/feature/add-displayname
Add displayName attribute to SAML response
2 parents c8709fc + c4f26e7 commit 6785080

4 files changed

Lines changed: 33 additions & 2 deletions

File tree

features/bootstrap/LoginContext.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function __construct()
7474
$this->request = new Request();
7575

7676
$this->resetDatabase();
77+
parent::__construct();
7778
}
7879

7980
protected function addXFailedLoginUsernames(int $number, $username)
@@ -276,6 +277,32 @@ public function iShouldBeAllowedThrough()
276277
Assert::notEmpty($userInfo);
277278
}
278279

280+
/**
281+
* @Then I should have the correct attributes
282+
*/
283+
public function iShouldHaveTheCorrectAttributes()
284+
{
285+
Assert::true(
286+
$this->authenticator->isAuthenticated()
287+
);
288+
$userInfo = $this->authenticator->getUserAttributes();
289+
Assert::keyExists($userInfo, "eduPersonPrincipalName");
290+
Assert::keyExists($userInfo, "eduPersonUniqueId");
291+
Assert::keyExists($userInfo, "sn");
292+
Assert::keyExists($userInfo, "givenName");
293+
Assert::keyExists($userInfo, "displayName");
294+
Assert::keyExists($userInfo, "mail");
295+
Assert::keyExists($userInfo, "employeeNumber");
296+
Assert::keyExists($userInfo, "cn");
297+
Assert::keyExists($userInfo, "schacExpiryDate");
298+
Assert::keyExists($userInfo, "mfa");
299+
Assert::keyExists($userInfo, "method");
300+
Assert::keyExists($userInfo, "uuid");
301+
Assert::keyExists($userInfo, "manager_email");
302+
Assert::keyExists($userInfo, "profile_review");
303+
Assert::keyExists($userInfo, "member");
304+
}
305+
279306
/**
280307
* @When I try to log in enough times to trigger the rate limit
281308
*/

features/login.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Feature: User login
8585
When I try to log in
8686
Then I should not see an error message
8787
And I should be allowed through
88+
And I should have the correct attributes
8889

8990
Scenario: Providing too many incorrect username-password combinations
9091
Given I provide a username

modules/silauth/src/Auth/Source/auth/IdBroker.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public function getAuthenticatedUser(string $username, string $password): ?array
9494
$userInfo['method'],
9595
$userInfo['manager_email'] ?? null,
9696
$userInfo['profile_review'] ?? 'no',
97-
$userInfo['member'] ?? []
97+
$userInfo['member'] ?? [],
98+
$userInfo['display_name'],
9899
);
99100
}
100101
}

modules/silauth/src/Auth/Source/saml/User.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public static function convertToSamlFieldNames(
1717
array $method,
1818
?string $managerEmail,
1919
string $profileReview,
20-
array $member
20+
array $member,
21+
string $displayName
2122
): array {
2223

2324
// eduPersonUniqueId (only alphanumeric allowed)
@@ -47,6 +48,7 @@ public static function convertToSamlFieldNames(
4748

4849
'sn' => (array)$lastName,
4950
'givenName' => (array)$firstName,
51+
'displayName' => (array)$displayName,
5052
'mail' => (array)$email,
5153
'employeeNumber' => (array)$employeeId,
5254
'cn' => (array)$username,

0 commit comments

Comments
 (0)