From 5fe6d20c396d3179a0ab58dd0e888a7000cca009 Mon Sep 17 00:00:00 2001 From: atisne Date: Mon, 23 Dec 2024 12:19:27 +0100 Subject: [PATCH 1/2] Minor improvement, typos --- auth.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/auth.php b/auth.php index b4dfdf8..6340523 100644 --- a/auth.php +++ b/auth.php @@ -126,6 +126,7 @@ public function __construct() { 'getUserCount' => 'get user counts', 'getGroups' => 'get groups', 'logout' => 'logout users', + 'external' => 'external auth', ); foreach ($this->cando as $key => $value) { if ($this->cando[$key]) @@ -196,7 +197,7 @@ public function trustExternal($user, $pass, $sticky = false) { $user = $_SERVER['REMOTE_USER']; $this->_debug( 'authsplit:trustExternal(): derived user name: ' . $user, - -1, __LINE__, __FILE__ + 1, __LINE__, __FILE__ ); /* Then make sure the secondary auth plugin also knows about the @@ -335,8 +336,8 @@ public function getUserData($user, $requireGroups = true) { $userinfo = $this->authplugins['primary']->getUserData($user, false); if (!$userinfo) { $this->_debug( - 'authsplit:checkPass(): primary auth plugin\'s getUserData() '. - 'failed, seems user is yet unknown there.', 1, + 'authsplit:getUserData(): primary auth plugin\'s getUserData() '. + 'failed, seems user is yet unknown there.', -1, __LINE__, __FILE__ ); return false; @@ -345,8 +346,8 @@ public function getUserData($user, $requireGroups = true) { $userinfo = $this->authplugins['secondary']->getUserData($user, $requireGroups); if (!$userinfo) { $this->_debug( - 'authsplit:checkPass(): secondary auth plugin\'s getUserData() '. - 'failed, seems user is yet unknown there.', 1, + 'authsplit:getUserData(): secondary auth plugin\'s getUserData() '. + 'failed, seems user is yet unknown there.', -1, __LINE__, __FILE__ ); return false; From c9807022ae6e3da06ebc084b171be602c095b53b Mon Sep 17 00:00:00 2001 From: atisne Date: Mon, 23 Dec 2024 12:26:44 +0100 Subject: [PATCH 2/2] Make the plugin compliant with the OAuth one Add missing methods called by OAuth as primary plugin. --- auth.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/auth.php b/auth.php index 6340523..b90035c 100644 --- a/auth.php +++ b/auth.php @@ -317,6 +317,38 @@ public function logIn() { return $this->authplugins['primary']->logIn(); } + /** + * Get an option of the primary auth method + * + * @param string $option The name of the wanted option + * + * @return string The option value of the primary method + */ + public function getOption($option) { + return $this->authplugins['primary']->getOption($option); + } + + /** + * Call to the register method of the primary auth + * + * @param array $userdata User to register + * @param string $servicename Service name + * + * @return bool Status of the registration + */ + public function registerOAuthUser(&$userdata, $servicename) { + $register = $this->authplugins['primary']->registerOAuthUser($userdata, $servicename); + if (!$register) { + $this->_debug( + 'authsplit:registerOAuthUser(): primary auth plugin\'s registerOAuthUser() '. + 'failed.', -1, __LINE__, __FILE__ + ); + return false; + } + + return $register; + } + /** * Return user info * @@ -360,6 +392,29 @@ public function getUserData($user, $requireGroups = true) { return $userinfo; } + /** + * Find a user by email address + * + * @param string user's email + * @return bool|string + */ + public function getUserByEmail($email) { + $user = $this->authplugins['primary']->getUserByEmail($email); + if (!$user) { + $this->_debug( + 'authsplit:getUserByEmail(): primary auth plugin\'s getUserByEmail() '. + 'failed.', -1, __LINE__, __FILE__ + ); + return false; + } + $this->_debug( + 'authsplit:getUserByEmail(): primary auth plugin\'s getUserByEmail(): '. + $user.'.', 1, __LINE__, __FILE__ + ); + + return $user; + } + /** * Returns a string representation of user data for debugging purposes *