horse icon indicating copy to clipboard operation
horse copied to clipboard

HTTPS with Let's Encrypt

Open SysIbba opened this issue 3 years ago • 2 comments

Hi, there are some example to explain how use certificate https in THorse daemon project ? In alternative, there are some example to explain how create an Apache Module and how configure Apache to use it ?

Thank you

SysIbba avatar Jul 05 '22 15:07 SysIbba

Not recommended, but enjoy it: https://www.youtube.com/watch?v=F1hMwxtKJs0

On Apache, you might find a lot's options on Google, since it is a wide known application

Subtitles are available.

igorbastosib avatar Jul 05 '22 15:07 igorbastosib

Sorry I return on this post ..... I have create an apache module for implement all my RESTful method. Now ... I don't know if this post is in the correct thread but i try ...

The question is ... there is a way to read the Apache "SetEnv" variables from Horse ?

The proble is that in my "BasicAuthorization" callbak I have the necessity to read a config file to access at the DB for validate a user login.

In the normal get/post/put I can access to the "Req.RawWebRequest.PathTranslated" that return me the correct directory of my location and I can load my configuration file ... but in my BasicAuthorization this is not possibile ...

This is my Registry

THorse.AddCallback(BasicAuthorization()).Get('/login', DoGetLogin);

function DoBasicAuthentication(const Username, Password: string): Boolean;
var
  Users: TServiceUsers;
begin
  Users := TServiceUsers.Create;
  try
//    {$IFDEF HORSE_APACHE}
//      var sx : String := Req.RawWebRequest.PathInfo;
//      var sp : String := Req.RawWebRequest.PathTranslated;
//      sp := sp.Replace('\','');
//      sx := sx.Replace('\','');
//      sp := sp.Replace(sx,'') + '/CFG_PGM.ini';
//
//      Users.fHomeSetDir := sp;
//    {$ENDIF}
//
//    Users.ConnectDB;
    Result := Users.IsValid(Username, Password);
  finally
    Users.Free;
  end;
end;

function BasicAuthorization: THorseCallback;
begin
  Result := HorseBasicAuthentication(DoBasicAuthentication);
end;

Thank's

SysIbba avatar Jul 10 '22 18:07 SysIbba

@SysIbba You can create your own private middleware, basic auth, and pass the Req and Res parameters to it, in addition to the Username and Password.

viniciussanchez avatar Feb 21 '23 20:02 viniciussanchez

@SysIbba conseguiu fazer?

dliocode avatar Mar 22 '23 20:03 dliocode