From 65bd7af60510cb464e3ed85306bb4f1f2f77040a Mon Sep 17 00:00:00 2001 From: Eric Woods Date: Thu, 5 Dec 2024 14:59:09 -0500 Subject: [PATCH] ShibIdentity improvements --- src/CUAuth/DataObjects/ShibIdentity.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/CUAuth/DataObjects/ShibIdentity.php b/src/CUAuth/DataObjects/ShibIdentity.php index eefcd82..0c482dc 100644 --- a/src/CUAuth/DataObjects/ShibIdentity.php +++ b/src/CUAuth/DataObjects/ShibIdentity.php @@ -27,7 +27,7 @@ public function __construct( public readonly string $idp, public readonly string $uid, public readonly string $displayName = '', - public readonly string $mail = '', + public readonly string $email = '', public readonly array $serverVars = [], ) {} @@ -46,14 +46,18 @@ public static function fromServerVars(?array $serverVars = null): self displayName: $serverVars['displayName'] ?? $serverVars['cn'] ?? trim(($serverVars['givenName'] ?? '').' '.($serverVars['sn'] ?? '')), - mail: $serverVars['eduPersonPrincipalName'] + email: $serverVars['eduPersonPrincipalName'] ?? $serverVars['mail'] ?? '', serverVars: $serverVars, ); } - public static function getRemoteUser(Request $request): ?string + public static function getRemoteUser(?Request $request = null): ?string { + if (empty($request)) { + $request = app('request'); + } + // If this is a local development environment, allow the local override. $remote_user_override = self::getRemoteUserOverride(); @@ -93,7 +97,7 @@ public function uniqueUid(): string */ public function email(): string { - return $this->mail; + return $this->email; } /**