Skip to content

Commit 2a45065

Browse files
Added a new
1 parent d3f4479 commit 2a45065

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

boss-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"hash": "8a53e9cf872feaac975a8fad2c6a5af0",
3-
"updated": "2022-02-16T08:58:42.6439434-03:00",
3+
"updated": "2021-10-04T08:54:27.0678585-03:00",
44
"installedModules": {
55
"github.com/hashload/horse": {
66
"name": "horse",
7-
"version": "3.0.0",
8-
"hash": "195e14c9c225f81a8c69d18b5118c149",
7+
"version": "3.0.1",
8+
"hash": "4533d4457de32678b73d0f990ded34c8",
99
"artifacts": {},
1010
"failed": false,
1111
"changed": false

src/Horse.BasicAuthentication.pas

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
unit Horse.BasicAuthentication;
22

33
{$IF DEFINED(FPC)}
4-
{$MODE DELPHI}{$H+}
4+
{$MODE DELPHI}{$H+}
55
{$ENDIF}
66

77
interface
@@ -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;
175177
end;
176178

179+
function THorseBasicAuthenticationConfig.SkipRoutes(const AValue: string): IHorseBasicAuthenticationConfig;
180+
begin
181+
Result := SkipRoutes([AValue]);
182+
end;
183+
177184
function THorseBasicAuthenticationConfig.SkipRoutes(const AValues: TArray<string>): IHorseBasicAuthenticationConfig;
178185
var
179186
I: Integer;

0 commit comments

Comments
 (0)