Delphi XE2 idHttpServer BASIC身份验证

时间:2017-03-22 18:07:11

标签: authentication http-headers delphi-xe2 indy10

我有一个工作正常的idHttpServer服务器,我提出了这样的基本身份验证:

procedure TfrmMain.IdHTTPServer1CommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
Var
     Cmd           : String;
     Retorno       : string;
begin
     Cmd := ARequestInfo.RawHTTPCommand;

     if  Not ((ARequestInfo.AuthUsername = 'user') and
              (ARequestInfo.AuthPassword = 'pass'))
     Then Begin
         AResponseInfo.AuthRealm := 'Forneça autenticação';
         AResponseInfo.WriteContent;
         Exit;
     End;

     // Do the Work
     // ....
End;

没关系,它正常工作,如果浏览器中的用户没有提供身份验证,浏览器会询问用户和密码。好的!

一旦用户提供了密码并且服务器完成了工作,在下一个请求时,服务器不会再次请求拒绝的身份验证,因为它认为它已在先前的请求中提供,即< / p>

ARequestInfo.AuthUsername  And ARequestInfo.AuthPassword 

总是在下一个请购单中预先填写,而浏览器不会询问用户。

如果我退出浏览器并再次开始继续执行其他请求,则会继续执行而不会要求进行身份验证。

有没有办法让浏览器始终要求对所有请求进行身份验证?

0 个答案:

没有答案