Skip to content

Instantly share code, notes, and snippets.

@St0iK
Created September 22, 2015 10:46
Show Gist options
  • Save St0iK/a34fb8f3feba934022f8 to your computer and use it in GitHub Desktop.
Save St0iK/a34fb8f3feba934022f8 to your computer and use it in GitHub Desktop.
Securing Magmi UI access
function authenticate($username=”“,$password=”“){
require "../../app/Mage.php";
Mage::app('default');
$user = Mage::getModel('admin/user');
$user->login($username,$password);
$result = $user->getId();
return $result ? true : false;
}
if (!isset($_SERVER[‘PHP_AUTH_USER’])) {
header('WWW-Authenticate:Basic realm="Magmi"');
header('HTTP/1.0 401 Unauthorized');
echo 'You must be logged in to use Magmi';
die();
} else {
if (!authenticate($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'])){
header('WWW-Authenticate: Basic realm="Magmi"');
header('HTTP/1.0 401 Unauthorized');
echo 'You must be logged in to use Magmi';
die();
}
}
/***************** *********************/
@olmoszamudio
Copy link

Doesn't work in Magento Community 1.9. I put the Magento admin username and password and continues to call me again and again. Should I replace something to make it work?

http://www.buenamarca.com/magmi/web/magmi.php

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment