File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 "mainsrc" : " /src" ,
77 "projects" : [],
88 "dependencies" : {
9- "github.com/hashload/horse" : " ^v1.6.6 "
9+ "github.com/hashload/horse" : " ^v2.0.0 "
1010 }
1111}
Original file line number Diff line number Diff line change @@ -20,17 +20,19 @@ interface
2020 THorseBasicAuthentication = { $IF NOT DEFINED(FPC)} reference to { $ENDIF} function(const AUsername, APassword: string): Boolean;
2121
2222procedure Middleware (Req: THorseRequest; Res: THorseResponse; Next: { $IF DEFINED(FPC)} TNextProc { $ELSE} TProc { $ENDIF} );
23- function HorseBasicAuthentication (const AAuthenticate: THorseBasicAuthentication; const AHeader: string = AUTHORIZATION): THorseCallback;
23+ function HorseBasicAuthentication (const AAuthenticate: THorseBasicAuthentication; const AHeader: string = AUTHORIZATION; const ARealmMessage: string = ' Enter credentials ' ): THorseCallback;
2424
2525implementation
2626
2727var
2828 Header: string;
29+ RealmMessage: string;
2930 Authenticate: THorseBasicAuthentication;
3031
31- function HorseBasicAuthentication (const AAuthenticate: THorseBasicAuthentication; const AHeader: string = AUTHORIZATION): THorseCallback;
32+ function HorseBasicAuthentication (const AAuthenticate: THorseBasicAuthentication; const AHeader: string = AUTHORIZATION; const ARealmMessage: string = ' Enter credentials ' ): THorseCallback;
3233begin
3334 Header := AHeader;
35+ RealmMessage := ARealmMessage;
3436 Authenticate := AAuthenticate;
3537 Result := Middleware;
3638end ;
@@ -47,7 +49,7 @@ procedure Middleware(Req: THorseRequest; Res: THorseResponse; Next: {$IF DEFINED
4749 LBasicAuthenticationEncode := Req.Headers[Header];
4850 if LBasicAuthenticationEncode.Trim.IsEmpty and not Req.Query.TryGetValue(Header, LBasicAuthenticationEncode) then
4951 begin
50- Res.Send(' Authorization not found' ).Status(THTTPStatus.Unauthorized);
52+ Res.Send(' Authorization not found' ).Status(THTTPStatus.Unauthorized).RawWebResponse.Realm := RealmMessage; ;
5153 raise EHorseCallbackInterrupted.Create;
5254 end ;
5355 if not LBasicAuthenticationEncode.ToLower.StartsWith(BASIC_AUTH) then
You can’t perform that action at this time.
0 commit comments