[ticket/16955] Clean up auth classes

PHPBB3-16955
This commit is contained in:
Marc Alexander 2022-12-27 17:42:23 +01:00
parent 5756d4dd9b
commit eeeb69b4ae
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
5 changed files with 24 additions and 36 deletions

View file

@ -23,7 +23,6 @@ abstract class base implements provider_interface
*/
public function init()
{
return;
}
/**
@ -31,7 +30,6 @@ abstract class base implements provider_interface
*/
public function autologin()
{
return;
}
/**
@ -39,7 +37,6 @@ abstract class base implements provider_interface
*/
public function acp()
{
return;
}
/**
@ -47,7 +44,6 @@ abstract class base implements provider_interface
*/
public function get_acp_template($new_config)
{
return;
}
/**
@ -55,7 +51,6 @@ abstract class base implements provider_interface
*/
public function get_login_data()
{
return;
}
/**
@ -63,7 +58,6 @@ abstract class base implements provider_interface
*/
public function get_auth_link_data($user_id = 0)
{
return;
}
/**
@ -71,7 +65,6 @@ abstract class base implements provider_interface
*/
public function logout($data, $new_session)
{
return;
}
/**
@ -79,7 +72,6 @@ abstract class base implements provider_interface
*/
public function validate_session($user)
{
return;
}
/**
@ -87,7 +79,6 @@ abstract class base implements provider_interface
*/
public function login_link_has_necessary_data(array $login_link_data)
{
return;
}
/**
@ -95,7 +86,6 @@ abstract class base implements provider_interface
*/
public function link_account(array $link_data)
{
return;
}
/**
@ -103,6 +93,5 @@ abstract class base implements provider_interface
*/
public function unlink_account(array $link_data)
{
return;
}
}

View file

@ -218,7 +218,7 @@ class oauth extends base
'oauth_provider_id' => (string) $unique_id
];
$sql = 'SELECT user_id
$sql = 'SELECT user_id
FROM ' . $this->oauth_account_table . '
WHERE ' . $this->db->sql_build_array('SELECT', $data);
$result = $this->db->sql_query($sql);
@ -240,6 +240,7 @@ class oauth extends base
* @var ServiceInterface service OAuth service
* @since 3.2.3-RC1
* @changed 3.2.6-RC1 Added redirect_data
* @psalm-var string[] $vars
*/
$vars = [
'row',
@ -423,8 +424,6 @@ class oauth extends base
{
return 'LOGIN_LINK_MISSING_DATA';
}
return null;
}
/**
@ -618,8 +617,8 @@ class oauth extends base
* @param array $link_data The same variable given to
* {@see \phpbb\auth\provider\provider_interface::link_account}
* @param string $service_name The name of the service being used in linking.
* @return string|false Returns a language constant (string) if an error is encountered,
* or false on success.
* @return array|string|false Returns a language constant (string) if an error is encountered,
* an array with error info or false on success.
*/
protected function link_account_auth_link(array $link_data, $service_name)
{
@ -828,8 +827,8 @@ class oauth extends base
* Sets a redirect to the authorization uri.
*
* @param OAuth1Service|OAuth2Service $service The external OAuth service
* @return array|false Array if an error occurred,
* false on success
* @return array Array if an error occurred,
* won't return on success
*/
protected function set_redirect($service)
{
@ -854,6 +853,6 @@ class oauth extends base
redirect($service->getAuthorizationUri($parameters), false, true);
return false;
return [];
}
}

View file

@ -263,7 +263,7 @@ class token_storage implements TokenStorageInterface
$data['session_id'] = $this->user->data['session_id'];
}
return $this->get_state_row($data);
return $this->get_state_row($data)['oauth_state'] ?? '';
}
/**
@ -519,7 +519,7 @@ class token_storage implements TokenStorageInterface
*
* @param array $data The SQL WHERE data
* @return array|false array with the OAuth state row,
* false if the state does not exist
* false if the state does not exist
*/
protected function get_state_row($data)
{

View file

@ -25,8 +25,8 @@ interface provider_interface
* Changing to an authentication provider will not be permitted in acp_board
* if there is an error.
*
* @return boolean|string False if the user is identified, otherwise an
* error message, or null if not implemented.
* @return bool|string|void False if the user is identified, otherwise an
* error message, or void if not implemented.
*/
public function init();
@ -52,8 +52,8 @@ interface provider_interface
/**
* Autologin function
*
* @return array|null containing the user row, empty if no auto login
* should take place, or null if not implemented.
* @return array|void containing the user row, empty if no auto login
* should take place, or void if not implemented.
*/
public function autologin();
@ -61,7 +61,7 @@ interface provider_interface
* This function is used to output any required fields in the authentication
* admin panel. It also defines any required configuration table fields.
*
* @return array|null Returns null if not implemented or an array of the
* @return array|void Returns void if not implemented or an array of the
* configuration fields of the provider.
*/
public function acp();
@ -74,7 +74,7 @@ interface provider_interface
*
* @param \phpbb\config\config $new_config Contains the new configuration values
* that have been set in acp_board.
* @return array|null Returns null if not implemented or an array with
* @return array|void Returns void if not implemented or an array with
* the template file name and an array of the vars
* that the template needs that must conform to the
* following example:
@ -107,8 +107,8 @@ interface provider_interface
* Returns an array of data necessary to build custom elements on the login
* form.
*
* @return array|null If this function is not implemented on an auth
* provider then it returns null. If it is implemented
* @return array|void If this function is not implemented on an auth
* provider then it returns void. If it is implemented
* it will return an array of up to four elements of
* which only 'TEMPLATE_FILE'. If 'BLOCK_VAR_NAME' is
* present then 'BLOCK_VARS' must also be present in
@ -139,8 +139,8 @@ interface provider_interface
* into phpBB.
*
* @param array $user
* @return boolean true if the given user is authenticated, false if the
* session should be closed, or null if not implemented.
* @return bool|void true if the given user is authenticated, false if the
* session should be closed, or void if not implemented.
*/
public function validate_session($user);
@ -151,8 +151,8 @@ interface provider_interface
*
* @param array $login_link_data Any data needed to link a phpBB account to
* an external account.
* @return string|null Returns a string with a language constant if there
* is data missing or null if there is no error.
* @return string|void Returns a string with a language constant if there
* is data missing or void if there is no error.
*/
public function login_link_has_necessary_data(array $login_link_data);
@ -171,8 +171,8 @@ interface provider_interface
* defaults to 0, which is not a valid ID. The method
* should fall back to the current user's ID in this
* case.
* @return array|null If this function is not implemented on an auth
* provider then it returns null. If it is implemented
* @return array|void If this function is not implemented on an auth
* provider then it returns void. If it is implemented
* it will return an array of up to four elements of
* which only 'TEMPLATE_FILE'. If 'BLOCK_VAR_NAME' is
* present then 'BLOCK_VARS' must also be present in

View file

@ -571,7 +571,7 @@ abstract class driver implements driver_interface
*/
function sql_build_array($query, $assoc_ary = [])
{
if (!count($assoc_ary))
if (!is_array($assoc_ary) || !count($assoc_ary))
{
return false;
}