Loading modules/o365_sso/src/Controller/UserLoginController.php +16 −1 Original line number Diff line number Diff line Loading @@ -118,7 +118,7 @@ class UserLoginController extends ControllerBase { // If we haven't found an account to link, create one from the data. if (!$account) { $accountData = [ 'name' => $userData['displayName'], 'name' => $this->sanitizeUsername($userData['displayName']), 'mail' => $userData['userPrincipalName'], ]; $account = $this->externalAuth->register($o365_id, 'o365_sso', $accountData); Loading @@ -135,4 +135,19 @@ class UserLoginController extends ControllerBase { return new RedirectResponse($redirectUrl); } /** * Sanitize username. * * @param string $username * The username coming from o365. * * @return string $username * The sanitized username. */ public function sanitizeUsername($username) { // Strip illegal characters. $username = preg_replace('/[^\\x{80}-\\x{F7} a-zA-Z0-9@_.\'-]/', '', $username); return $username; } } Loading
modules/o365_sso/src/Controller/UserLoginController.php +16 −1 Original line number Diff line number Diff line Loading @@ -118,7 +118,7 @@ class UserLoginController extends ControllerBase { // If we haven't found an account to link, create one from the data. if (!$account) { $accountData = [ 'name' => $userData['displayName'], 'name' => $this->sanitizeUsername($userData['displayName']), 'mail' => $userData['userPrincipalName'], ]; $account = $this->externalAuth->register($o365_id, 'o365_sso', $accountData); Loading @@ -135,4 +135,19 @@ class UserLoginController extends ControllerBase { return new RedirectResponse($redirectUrl); } /** * Sanitize username. * * @param string $username * The username coming from o365. * * @return string $username * The sanitized username. */ public function sanitizeUsername($username) { // Strip illegal characters. $username = preg_replace('/[^\\x{80}-\\x{F7} a-zA-Z0-9@_.\'-]/', '', $username); return $username; } }