Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosHe committed Mar 1, 2023
1 parent 2b457ba commit 5d34226
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions src/Horse.JWT.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ interface
function SkipRoutes(const ARoute: string): IHorseJWTConfig; overload;
function Header: string; overload;
function Header(const AValue: string): IHorseJWTConfig; overload;
function IsRequiredSubject: boolean; overload;
function IsRequiredSubject(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequiredIssuedAt: boolean; overload;
function IsRequiredIssuedAt(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequiredNotBefore: boolean; overload;
function IsRequiredNotBefore(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequiredExpirationTime: boolean; overload;
function IsRequiredExpirationTime(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequireAudience: boolean; overload;
function IsRequireAudience(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequiredSubject: Boolean; overload;
function IsRequiredSubject(const AValue: Boolean): IHorseJWTConfig; overload;
function IsRequiredIssuedAt: Boolean; overload;
function IsRequiredIssuedAt(const AValue: Boolean): IHorseJWTConfig; overload;
function IsRequiredNotBefore: Boolean; overload;
function IsRequiredNotBefore(const AValue: Boolean): IHorseJWTConfig; overload;
function IsRequiredExpirationTime: Boolean; overload;
function IsRequiredExpirationTime(const AValue: Boolean): IHorseJWTConfig; overload;
function IsRequireAudience: Boolean; overload;
function IsRequireAudience(const AValue: Boolean): IHorseJWTConfig; overload;
function ExpectedAudience: TArray<string>; overload;
function ExpectedAudience(const AValue: TArray<string>): IHorseJWTConfig; overload;
function SessionClass: TClass; overload;
Expand All @@ -68,28 +68,28 @@ THorseJWTConfig = class(TInterfacedObject, IHorseJWTConfig)
private
FHeader: string;
FSkipRoutes: TArray<string>;
FIsRequireAudience: boolean;
FIsRequireAudience: Boolean;
FExpectedAudience: TArray<string>;
FIsRequiredExpirationTime: boolean;
FIsRequiredIssuedAt: boolean;
FIsRequiredNotBefore: boolean;
FIsRequiredSubject: boolean;
FIsRequiredExpirationTime: Boolean;
FIsRequiredIssuedAt: Boolean;
FIsRequiredNotBefore: Boolean;
FIsRequiredSubject: Boolean;
FSessionClass: TClass;
function SkipRoutes: TArray<string>; overload;
function SkipRoutes(const ARoutes: TArray<string>): IHorseJWTConfig; overload;
function SkipRoutes(const ARoute: string): IHorseJWTConfig; overload;
function Header: string; overload;
function Header(const AValue: string): IHorseJWTConfig; overload;
function IsRequiredSubject: boolean; overload;
function IsRequiredSubject(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequiredIssuedAt: boolean; overload;
function IsRequiredIssuedAt(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequiredNotBefore: boolean; overload;
function IsRequiredNotBefore(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequiredExpirationTime: boolean; overload;
function IsRequiredExpirationTime(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequireAudience: boolean; overload;
function IsRequireAudience(const AValue: boolean): IHorseJWTConfig; overload;
function IsRequiredSubject: Boolean; overload;
function IsRequiredSubject(const AValue: Boolean): IHorseJWTConfig; overload;
function IsRequiredIssuedAt: Boolean; overload;
function IsRequiredIssuedAt(const AValue: Boolean): IHorseJWTConfig; overload;
function IsRequiredNotBefore: Boolean; overload;
function IsRequiredNotBefore(const AValue: Boolean): IHorseJWTConfig; overload;
function IsRequiredExpirationTime: Boolean; overload;
function IsRequiredExpirationTime(const AValue: Boolean): IHorseJWTConfig; overload;
function IsRequireAudience: Boolean; overload;
function IsRequireAudience(const AValue: Boolean): IHorseJWTConfig; overload;
function ExpectedAudience: TArray<string>; overload;
function ExpectedAudience(const AValue: TArray<string>): IHorseJWTConfig; overload;
function SessionClass: TClass; overload;
Expand Down Expand Up @@ -158,7 +158,7 @@ procedure Middleware(AHorseRequest: THorseRequest; AHorseResponse: THorseRespons
end;
end;

function ValidateSignature: boolean;
function ValidateSignature: Boolean;
var
LHMAC: IHMAC;
LSignCalc: String;
Expand All @@ -181,6 +181,7 @@ procedure Middleware(AHorseRequest: THorseRequest; AHorseResponse: THorseRespons
Result := (LJWT.Signature = LSignCalc);
end;
{$ENDIF}

begin
LPathInfo := AHorseRequest.RawWebRequest.PathInfo;
if LPathInfo = EmptyStr then
Expand Down Expand Up @@ -363,57 +364,57 @@ function THorseJWTConfig.Header(const AValue: string): IHorseJWTConfig;
Result := Self;
end;

function THorseJWTConfig.IsRequiredSubject: boolean;
function THorseJWTConfig.IsRequiredSubject: Boolean;
begin
Result := FIsRequiredSubject;
end;

function THorseJWTConfig.IsRequiredSubject(const AValue: boolean): IHorseJWTConfig;
function THorseJWTConfig.IsRequiredSubject(const AValue: Boolean): IHorseJWTConfig;
begin
FIsRequiredSubject := AValue;
Result := Self;
end;

function THorseJWTConfig.IsRequiredIssuedAt: boolean;
function THorseJWTConfig.IsRequiredIssuedAt: Boolean;
begin
Result := FIsRequiredIssuedAt;
end;

function THorseJWTConfig.IsRequiredIssuedAt(const AValue: boolean): IHorseJWTConfig;
function THorseJWTConfig.IsRequiredIssuedAt(const AValue: Boolean): IHorseJWTConfig;
begin
FIsRequiredIssuedAt := AValue;
Result := Self;
end;

function THorseJWTConfig.IsRequiredNotBefore: boolean;
function THorseJWTConfig.IsRequiredNotBefore: Boolean;
begin
Result := FIsRequiredNotBefore;
end;

function THorseJWTConfig.IsRequiredNotBefore(const AValue: boolean): IHorseJWTConfig;
function THorseJWTConfig.IsRequiredNotBefore(const AValue: Boolean): IHorseJWTConfig;
begin
FIsRequiredNotBefore := AValue;
Result := Self;
end;

function THorseJWTConfig.IsRequiredExpirationTime: boolean;
function THorseJWTConfig.IsRequiredExpirationTime: Boolean;
begin
Result := FIsRequiredExpirationTime;
end;

function THorseJWTConfig.IsRequiredExpirationTime(
const AValue: boolean): IHorseJWTConfig;
const AValue: Boolean): IHorseJWTConfig;
begin
FIsRequiredExpirationTime := AValue;
Result := Self;
end;

function THorseJWTConfig.IsRequireAudience: boolean;
function THorseJWTConfig.IsRequireAudience: Boolean;
begin
Result := FIsRequireAudience;
end;

function THorseJWTConfig.IsRequireAudience(const AValue: boolean): IHorseJWTConfig;
function THorseJWTConfig.IsRequireAudience(const AValue: Boolean): IHorseJWTConfig;
begin
FIsRequireAudience := AValue;
Result := Self;
Expand Down

0 comments on commit 5d34226

Please sign in to comment.