Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Feb : Re: HTTP username/password
| Subject: | Re: HTTP username/password |
| Posted by: | "E Sterrett" (e_sterre..@mailinator.com) |
| Date: | Fri, 29 Feb 2008 17:03:14 |
Remy Lebeau (TeamB) wrote:
> "E Sterrett" <e_sterrett@mailinator.com> wrote in message
> news:47c1d675$1@newsgroups.borland.com...
>
>> I have a very basic Indy 10 Http server (see below).
>>
>> What would be the simplest way to add authentication.
>
> TIdHTTPServer only supports BASIC authorization at this time. That support
> is built-in for you. In the OnCommandGet event, the TIdHTTPRequestInfo
> object has AuthUsername and AuthPassword properties that will be filled in
> when the client sends authorization credentials to your server.
>
>
> Gambiut
>
>
Thanks, I've tried the following code at the beginning of
httpServerCommandGet, but all I get is a blank screen.
What is the correct way to request authentication?
if (requestinfo.AuthPassword<>'pass') and
(requestinfo.AuthUsername<>'admin') then
begin
ResponseInfo.ResponseNo := 401;
ResponseInfo.ResponseText := 'Authorization required';
ResponseInfo.WriteHeader;
exit;
end;