Magento 2 plugin or script for external login

Job ID: 37879048

Budget: €8 – €30 EUR

$objectManager = GetManager(); // this is my function
$customer = getCustomer($email); // this is my function

if (is_null($customer))
{
echo "ERROR : User not exists<br>";
return ;
}

$userid = $customer->getId();

if ($userid >= 1)
{
$Result = authenticate($customer, $password); // this is my function
if ($Result)
{
$customerSession = $objectManager->create('\Magento\Customer\Model\Session');
$customerSession->loginById($userid);

$cacheManager = $objectManager->get('\Magento\Framework\App\Cache\Manager');
$cacheManager->flush($cacheManager->getAvailableTypes());

if ($customerSession->isLoggedIn())
echo "MSG : User correctly logged in<br>";
else echo "ERROR : User not logged in<br>";
}
else echo "ERROR : User not logged in<br>";
}

This code for Magento 2 allows login in the frontend but only works with Magento 2.3.3.
I want to create a plugin that allows login on all versions of Magento from 2.3.x or higher.
This plugin must receive username, password and a URL as parameters via a Get or Post call and log the user into the frontend.
If url is not empty, redirect to the indicated url.

Login must be possible with a call like this:
https://www.mydomain/device/version***/login/?username=******&password=*******&url=https://www........ or a post with curl
If the login was successful and the url parameter is not empty then the user must be redirected to the page indicated by url.

Furthermore, a php script must be added that allows the plugin to be installed remotely.

Installation must be possible with a call like this:
https://www.mydomain/device/version***/installplugin.php?filename=myzipfile
A zip file is copied into the device/version***/ folder and possibly decompressed.

This script must make all calls to composer ... to perform the installation.
I want the plugin installation to be automatic.
Related categories: PHP Magento MySQL