Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8967127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:10:42+00:00 2026-06-15T17:10:42+00:00

I want to do what is described here , but with Drupal 7. Before

  • 0

I want to do what is described here, but with Drupal 7.

Before version 7, passwords were saved in database as a md5 hash, so you could use Auth_MySQL.

In this example, I’m trying to allow access on gitweb only to valid drupal users:

File: /etc/apache2/sites-enabled/default-ssl

    <Directory /usr/share/gitweb>
            AuthName "site name"
            AuthType Basic

            Auth_MySQL On
            Auth_MySQL_Authoritative on

            Auth_MySQL_Host localhost
            Auth_MySQL_Username drupal_user
            Auth_MySQL_Password drupal_password
            Auth_MySQL_DB drupal_database
            Auth_MySQL_Password_Table users
            Auth_MySQL_Username_Field name
            Auth_MySQL_Password_Field pass
            Auth_MySQL_Encryption_Types PHP_MD5
            Auth_MySQL_Password_Clause " AND status=1"
            Auth_MySQL_Empty_Passwords Off

            AuthBasicAuthoritative Off
            AuthUserFile /dev/null

            require valid-user
    </Directory>

Looking into database, with select name,pass from users;, passwords hashes are like this: $S$DSmryVGZQg2AsLOFBT68xoQaEqPA1TWe4gi2gezh93tAjrbskFUi because they are “salted”, not classic md5 hash like in older drupal version?

I know that is possible to check if a password matches the hashed password with the function user_check_password($password, $account) =>api.

How to let Apache using Drupal 7 users/password as authentication system?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:10:44+00:00Added an answer on June 15, 2026 at 5:10 pm

    Finally, I’ve found the solution: mod-auth-external.

    Install the module, if it’s not yet installed

    sudo apt-get install libapache2-mod-authnz-external
    sudo a2enmod authnz_external
    

    Add this to http.conf

    DefineExternalAuth drupal environment /var/www/drupal-authentication.php
    

    Add this to .htaccess in protected directory:

    AuthType basic
    AuthName "GitWeb"
    AuthBasicProvider external
    AuthExternal drupal
    Require valid-user
    

    Edit /var/www/drupal-authentication.php (or where your drupal installation is)

    #!/usr/bin/php5
    <?php
    
    empty($_SERVER['SHELL']) && die('shells only please');
    
    define('DRUPAL_ROOT', '/var/www');
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    
    $username = getenv('USER');
    $password = getenv('PASS');
    
    $auth = user_authenticate($username, $password);
    
    if (!$auth) {
      exit(1);
    }
    
    exit(0);
    

    This example is working: when accessing /gitweb directory or any file inside it, browser asks for username and password. The login is successfull only if username and password match drupal’s one.

    Security

    I’m not sure how much safe this is. It needs testing.

    Performance

    drupal-authentication.php is called for each http request, so performance are low. You can improve efficience with mod_authz_socache as described here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do exactly what it is described here , but the accepted
I want to use send emails via Outlook as described here . It works
Short version: how can I detect overflow using the fixed-point multiplication described here but
I want to modify the solution for highlighting trailing whitespace described here by NOT
I want to do what is described here . I know I am kinda
I'm using the Coda Slider effect described here: http://jqueryfordesigners.com/coda-slider-effect/ . It works perfectly but
I have made a custom button bar as described here . Now, I want
I have tried to use the program described here Problems in deleting a Folder
I put the Android key hash in the developer settings, like described here: http://developers.facebook.com/docs/mobile/android/build/#sig
I'm using System.Net tracing as described here: http://ferozedaud.blogspot.com/2009/08/tracing-with-systemnet.html But that traces every request made

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.