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 6547653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:51:25+00:00 2026-05-25T11:51:25+00:00

so, we have a few folders in our source base that are htdigest protected.

  • 0

so, we have a few folders in our source base that are htdigest protected.

we would like to log invalid logins via our own custom php handler.

i was hoping on doing this via the apache ErrorDocument directive.

so i guess my question is two tiered.

a) is it valid to point an apache ErrorDocument directive at a php script, and will it be parsed as a php script (assuming php is up and running for said httpd).

b) i took a quick look at the http status code list at http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.


10.4.2 401 Unauthorized

The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitable Authorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity might include relevant diagnostic information. HTTP access authentication is explained in “HTTP Authentication: Basic and Digest Access Authentication” [43].


this makes it sound as tho the flow process, from a browser based useragent will be as follows:

a) user hits protected url
b) apache responds with a 401 status code
c) user is presented by useragent with username + password prompt

we only want to log invalid logins, not hits that do not know (yet) that the page requires authentication.

basically, and i’ll do a bit of a copy paste here, but what we want is a custom, php based replacement for the following:

Authorization Required

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

what we DON’T want to do:

a) be told that we should in this case be using a full php based login system. this is already done, the authentication is 2 tiered. user has to log into the service, via web based login (session based). and the 2nd tier of authentication is the http based authentication.

b) be told to setup a fully customized php based http authentication handler. yea, i know this is possible, and quite easy, but i would love to leave the actual htdigest handling in apaches hands. but, if leaving the http auth handling in apache’s hands is not possible, this will end up being what we will have to do.


so to summarize: is it possible to have apache parse a php based script on invalid htdigest logins (but not lack there of) so we can action within that script (log, ip block, etc…)?

  • 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-05-25T11:51:26+00:00Added an answer on May 25, 2026 at 11:51 am

    The following method works, as far as we can tell. Even with expiring htdigest based authentication:

    a) Point ErrorDocument 401 to a php based script.

    b) Our php 401 script looks as follows:

    <?
    
    if(isset($_SERVER['REDIRECT_REMOTE_USER'])){
        logError('authentication','invalid login attempt to '.(isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:'unknown').' using username '.$_SERVER['REDIRECT_REMOTE_USER']);
    }
    
    header($_SERVER['SERVER_PROTOCOL'].' 401 Authorization Required',true);
    header('Status: 401 Authorization Required',true);
    
    ?>
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
    <html><head> 
    <title>401 Authorization Required</title> 
    </head><body> 
    <h1>Authorization Required</h1> 
    <p>This server could not verify that you
    are authorized to access the document
    requested.  Either you supplied the wrong
    credentials (e.g., bad password), or your
    browser doesn't understand how to supply
    the credentials required.</p> 
    </body></html>
    

    The logError function is a custom function of ours, but you can replace it with whatever you like / add some further actions in there.

    Enjoy!

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

Sidebar

Related Questions

I have a VisualStudio project with a few sub folders like Accounting, Store etc.
We have a few 100 users logging in via FTP and uploading files. Our
I have a folder on my remote server that has a few .png files
I have few different applications among which I'd like to share a C# enum.
We have few components like libraries dlls When initially created I ran the following
I have a network storage device that contains a few hundred thousand mp3 files,
I have ASP.NET MVC Beta on our web server running a few apps. My
Say I have few folders in trunk trunk/documentation trunk/ApplicationServices trunk/Release trunk/ApplicationUI I want to
I have been working on standardizing the source control structure for our Team Foundation
We have found a problem with our deployment to a production server that runs

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.