Re: [users@httpd] How to detect failed authentification ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There was a time when I thought that the environment variable "REMOTE_USER" was set so the code handling the 401 condition could distinguish between the initial 401response and the 401 sent in response to an invalid username/password.  Of course, you still couldn't distinguish the case where the user didn't enter a username, but hopefully that doesn't happen too often.

I've even got code in my err401.cmd script which analyses the REMOTE_USER variable, telling them why their username was unacceptable.  So I have to assume that this worked, once. Surely I tested it????

However, newer releases of apache seem not to set the REMOTE_USER variable when it is not authenticated.

On 15/08/06, Boyle Owen <Owen.Boyle@xxxxxxx> wrote:
> -----Original Message-----
> From: Marc MENDEZ [mailto:cnmm600@xxxxxxxx]
> Sent: Tuesday, August 15, 2006 5:00 PM
> To: users@xxxxxxxxxxxxxxxx
> Subject: Re: [users@httpd] How to detect failed authentification ?
>
> thanks for your answer, that's what I thought.
>
> But, is there a solution to get a mail *only* when the login failed ?

As I said before... Not as far as I know. A quick look in the code (modules/aaa/mod_auth_basic.c) shows that mod_auth returns the same value (HTTP_UNAUTHORIZED) if there's no auth header OR wrong scheme OR password mismatch OR user not found

So you can't tell what caused the request to fail which means that no credentials (first request) = bad request.

The thing is that Basic Auth is, as the name implies, "basic". If you want to do clever stuff like you do, you really have to go for a cookie-driven login scheme that has more server-sided intelligence. Since you're already using PHP, there are lots of PHP-based closed user group solutions - search on www.php.net.

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored.



>
>
> ----- Original Message -----
> From: "Boyle Owen" < Owen.Boyle@xxxxxxx>
> To: <users@xxxxxxxxxxxxxxxx>
> Sent: Tuesday, August 15, 2006 3:04 PM
> Subject: RE: [users@httpd ] How to detect failed authentification ?
>
>
> > -----Original Message-----
> > From: Marc MENDEZ [mailto:cnmm600@xxxxxxxx]
> > Sent: Tuesday, August 15, 2006 2:32 PM
> > To: users@xxxxxxxxxxxxxxxx
> > Subject: [users@httpd] How to detect failed authentification ?
> >
> > Hi,
> >
> > On one of my website, the access is controled with a .htaccess file.
> > I defined my own 401 document
> >
> > At the top of this file, I added a php code which sends a
> mail to the
> > administrator as soon as a user failed to log.
> >
> > I was very surprised to receive mail everytime ! Even if the
> > user succeeds
> > in loging !
>
> I guess your PHP page is executed anytime the server sends a
> 401? If so,
> this is exactly what will happen...
>
> The server sends a 401 for any request that comes in without valid
> credentials. So the *first* request, which is sent when the
> client doesn't
> even know yet that the resource is protected, already triggers a 401.
>
> If this surprises you, read this
> http://en.wikipedia.org/wiki/Basic_authentication_scheme to
> see how basic
> auth really works...
>
> >
> > Why ? How can I solve this ?
>
> I don't think you can - the server doesn't distinguish between no
> credentials and bad credentials.
>
> Rgds,
> Owen Boyle
> Disclaimer: Any disclaimer attached to this message may be ignored.
>
> >
> >
> >
> >  p4.vert.ukl.yahoo.com uncompressed Tue Aug 15 12:27:00 GMT 2006
> >
> >
> > ______________________________________________________________
> > _____________
> > Découvrez un nouveau moyen de poser toutes vos questions
> > quelque soit le sujet !
> > Yahoo! Questions/Réponses pour partager vos connaissances,
> > vos opinions et vos expériences.
> > http://fr.answers.yahoo.com
> >
> >
> >
> ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP
> > Server Project.
> > See <URL: http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
> >    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
> >
>
>
> This message is for the named person's use only. It may contain
> confidential, proprietary or legally privileged information. No
> confidentiality or privilege is waived or lost by any
> mistransmission. If
> you receive this message in error, please notify the sender
> urgently and
> then immediately delete the message and any copies of it from
> your system.
> Please also immediately destroy any hardcopies of the
> message. You must not,
> directly or indirectly, use, disclose, distribute, print, or
> copy any part
> of this message if you are not the intended recipient. The
> sender's company
> reserves the right to monitor all e-mail communications through their
> networks. Any views expressed in this message are those of
> the individual
> sender, except where the message states otherwise and the sender is
> authorised to state them to be the views of the sender's company.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP
> Server Project.
> See <URL: http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>
>
>
>  p4.vert.ukl.yahoo.com uncompressed Tue Aug 15 14:27:01 GMT 2006
>
>
> ______________________________________________________________
> _____________
> Découvrez un nouveau moyen de poser toutes vos questions
> quelque soit le sujet !
> Yahoo! Questions/Réponses pour partager vos connaissances,
> vos opinions et vos expériences.
> http://fr.answers.yahoo.com
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>


This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please notify the sender urgently and then immediately delete the message and any copies of it from your system. Please also immediately destroy any hardcopies of the message. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. The sender's company reserves the right to monitor all e-mail communications through their networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of the sender's company.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html > for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




--
Steve Swift
http://www.swiftys.org.uk
[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux