.htpasswd / Espo login basic authentication fail -> Alternative Method Using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmcdonald
    Junior Member
    • Jun 2016
    • 8

    #1

    .htpasswd / Espo login basic authentication fail -> Alternative Method Using php

    Happens because shared hosting with AllowOverride None in apache httpd.cnf -


    You can use this instead:


    <?php

    /************************************************** **********************
    * This file is part of EspoCRM.
    *
    * EspoCRM - Open Source CRM application.
    * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
    * Website: http://www.espocrm.com
    *
    * EspoCRM is free software: you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation, either version 3 of the License, or
    * (at your option) any later version.
    *
    * EspoCRM is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with EspoCRM. If not, see http://www.gnu.org/licenses/.
    *
    * The interactive user interfaces in modified source and object code versions
    * of this program must display Appropriate Legal Notices, as required under
    * Section 5 of the GNU General Public License version 3.
    *
    * In accordance with Section 7(b) of the GNU General Public License version 3,
    * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
    ************************************************** **********************/


    // Check Username and password correct or ask for them
    if(($_SERVER['PHP_AUTH_USER'] == "myusername") AND
    ($_SERVER['PHP_AUTH_PW'] == "mypassword"))
    {
    include "bootstrap.php";

    $app = new \Espo\Core\Application();
    if (!$app->isInstalled()) {
    header("Location: install/");
    exit;
    }
    if (!empty($_GET['entryPoint'])) {
    $app->runEntryPoint($_GET['entryPoint']);
    exit;
    }

    $app->runClient();
    }
    else
    {
    // Ask for username and password
    header("WWW-Authenticate: " ."Basic realm="Espo Protected Area"");
    header("HTTP/1.0 401 Unauthorized");

    // Show failure text after several failed attempts
    echo "This area is protected by a valid username and password";
    }
    ?>


    you can substitute "myusername" "mypassword" with variables called from a require include page sitting below your webroot similar to .htpasswd.

  • AlexAv
    EspoCRM Team
    • May 2014
    • 124

    #2
    Interesting solution

    Comment

    Working...