HyperServer and HTTP Authentication

It is possible to work with HyperServer and applications that use one of the available HTTP authentication methods. HyperServer transparently relays all related headers to the Nodes and a Node can initiate an HTTP authentication session like a regular uniGUI application. This means that the actual authentication will occur inside user code provided in the Node application.

Here is a sample authentication code which allows a single user log on using basic authentication with a user name and password.

clip0360
ServerModule.pas
procedure TUniServerModule.UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo;
  AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean);
begin
  if ARequestInfo.AuthExists and
     (ARequestInfo.AuthPassword = '1234') and
     (ARequestInfo.AuthUsername = 'demo') then
  begin
    Exit; // Authentication is successful
  end
  else
  begin
    // Request authentication
    AResponseInfo.AuthRealm := 'Enter credentials for ' + Title;
    AResponseInfo.ResponseNo := 401;
    Handled := True;
  end;
end;

Since the authentication process is completely stateless, HyperServer may redirect the authentication requests to any of the active Nodes or create a new Node to serve the request.

If the URL includes a HyperServer application then the request will be directed to the related application Node.