11unit Horse.BasicAuthentication;
22
33{ $IF DEFINED(FPC)}
4- { $MODE DELPHI}{ $H+}
4+ { $MODE DELPHI}{ $H+}
55{ $ENDIF}
66
77interface
@@ -26,6 +26,7 @@ interface
2626 function RealmMessage (const AValue: string): IHorseBasicAuthenticationConfig; overload;
2727 function RealmMessage : string; overload;
2828 function SkipRoutes (const AValues: TArray<string>): IHorseBasicAuthenticationConfig; overload;
29+ function SkipRoutes (const AValue: string): IHorseBasicAuthenticationConfig; overload;
2930 function SkipRoutes : TArray<string>; overload;
3031 end ;
3132
@@ -39,6 +40,7 @@ THorseBasicAuthenticationConfig = class(TInterfacedObject, IHorseBasicAuthenti
3940 function RealmMessage (const AValue: string): IHorseBasicAuthenticationConfig; overload;
4041 function RealmMessage : string; overload;
4142 function SkipRoutes (const AValues: TArray<string>): IHorseBasicAuthenticationConfig; overload;
43+ function SkipRoutes (const AValue: string): IHorseBasicAuthenticationConfig; overload;
4244 function SkipRoutes : TArray<string>; overload;
4345 public
4446 constructor Create;
@@ -94,11 +96,11 @@ procedure Middleware(Req: THorseRequest; Res: THorseResponse; Next: {$IF DEFINED
9496 if LBasicAuthenticationEncode.Trim.IsEmpty and not Req.Query.TryGetValue(Config.Header, LBasicAuthenticationEncode) then
9597 begin
9698 Res.Send(' Authorization not found' ).Status(THTTPStatus.Unauthorized).RawWebResponse
97- { $IF DEFINED(FPC)}
99+ { $IF DEFINED(FPC)}
98100 .WWWAuthenticate := Format(' Basic realm=%s' , [Config.RealmMessage]);
99- { $ELSE}
101+ { $ELSE}
100102 .Realm := Config.RealmMessage;
101- { $ENDIF}
103+ { $ENDIF}
102104
103105 raise EHorseCallbackInterrupted.Create;
104106 end ;
@@ -174,6 +176,11 @@ function THorseBasicAuthenticationConfig.RealmMessage: string;
174176 Result := FRealmMessage;
175177end ;
176178
179+ function THorseBasicAuthenticationConfig.SkipRoutes (const AValue: string): IHorseBasicAuthenticationConfig;
180+ begin
181+ Result := SkipRoutes([AValue]);
182+ end ;
183+
177184function THorseBasicAuthenticationConfig.SkipRoutes (const AValues: TArray<string>): IHorseBasicAuthenticationConfig;
178185var
179186 I: Integer;
0 commit comments