1- unit uRESTDWAuthenticators;
1+ unit uRESTDWAuthenticators;
22
33{ $I ..\..\Includes\uRESTDW.inc}
44
@@ -32,20 +32,8 @@ interface
3232
3333uses
3434 Classes, SysUtils, DateUtils,
35- uRESTDWConsts, uRESTDWAbout, uRESTDWDataUtils, uRESTDWJSONInterface,
36- uRESTDWTools, uRESTDWParams, uRESTDWProtoTypes, uRESTDW.OpenSsl_11;
37-
38- Type
39- TRESTDWCertOptions = Record
40- Country,
41- State,
42- Locality,
43- Organization,
44- OrgUnit,
45- CommonName,
46- ServerName : String;
47- ExpiresDays : Integer;
48- End ;
35+ uRESTDWConsts, uRESTDWAbout, uRESTDWDataUtils, uRESTDWJSONInterface,
36+ uRESTDWTools, uRESTDWParams;
4937
5038Type
5139 TRESTDWAuthenticatorBase = class (TRESTDWComponent)
@@ -150,63 +138,36 @@ TRESTDWAuthToken = class(TRESTDWServerAuthBase)
150138 property AutoRenewToken: Boolean read FAutoRenewToken write FAutoRenewToken;
151139 end ;
152140
153- TRESTDWAuthOAuth = Class (TRESTDWServerAuthBase)
141+ TRESTDWAuthOAuth = class (TRESTDWServerAuthBase)
154142 private
155- FTokenType : TRESTDWAuthOptionTypes;
156- FBeginTime,
157- FEndTime : TDateTime;
158- FRSASHA256_Validation,
159- FServerValidationCert,
160- FAutoBuildHex : Boolean;
161- FLifeCycle : Integer;
162- FToken,
163- FGrantCodeEvent,
164- FGrantType,
165- FGetTokenEvent,
166- FHeader,
167- FPayLoad,
168- FSignature,
169- FPublicKey,
170- FPrivateKey,
171- FRedirectURI : String;
143+ FTokenType: TRESTDWAuthOptionTypes;
144+ FAutoBuildHex: Boolean;
145+ FToken: String;
146+ FGrantCodeEvent: String;
147+ FGrantType: String;
148+ FGetTokenEvent: String;
149+ FClientID: String;
150+ FClientSecret: String;
151+ FRedirectURI: String;
152+ FExpiresIn: TDateTime;
172153 public
173- Constructor Create (aOwner : TComponent); Override;
174- Function CreateSelfSignedCert_X509 (CertOptions : TRESTDWCertOptions;
175- Var Certificate,
176- PrivateKey : TRESTDWBytes) : Boolean;
177- Function AuthValidate (ADataModuleRESTDW : TObject;
178- AUrlToExec,
179- AWelcomeMessage,
180- AAccessTag,
181- AAuthUsername,
182- AAuthPassword : String;
183- ARawHeaders : TStrings;
184- ARequestType : TRequestType;
185- Var ADWParams : TRESTDWParams;
186- Var AGetToken : Boolean;
187- Var ATokenValidate : Boolean;
188- Var AToken : String;
189- Var AErrorCode : Integer;
190- Var AErrorMessage : String;
191- Var AAcceptAuth : Boolean) : Boolean; Override;
154+ constructor Create(aOwner: TComponent); override;
155+ function AuthValidate (ADataModuleRESTDW: TObject;
156+ AUrlToExec, AWelcomeMessage, AAccessTag, AAuthUsername, AAuthPassword: String;
157+ ARawHeaders: TStrings; ARequestType: TRequestType; var ADWParams: TRESTDWParams;
158+ var AGetToken: Boolean; var ATokenValidate: Boolean; var AToken: String;
159+ var AErrorCode: Integer; var AErrorMessage: String; var AAcceptAuth: Boolean): Boolean; override;
192160 published
193- Property TokenType : TRESTDWAuthOptionTypes Read FTokenType Write FTokenType;
194- Property AutoBuildHex : Boolean Read FAutoBuildHex Write FAutoBuildHex;
195- Property RSASHA256_Validation : Boolean Read FRSASHA256_Validation Write FRSASHA256_Validation;
196- Property LifeCycle : Integer Read FLifeCycle Write FLifeCycle;
197- Property BeginTime : TDateTime Read FBeginTime Write FBeginTime; // iat
198- Property EndTime : TDateTime Read FEndTime Write FEndTime;// exp
199- Property ServerValidationCert : Boolean Read FServerValidationCert Write FServerValidationCert;
200- Property Token : String Read FToken Write FToken;
201- Property GrantCodeEvent : String Read FGrantCodeEvent Write FGrantCodeEvent;
202- Property GrantType : String Read FGrantType Write FGrantType;
203- Property GetTokenEvent : String Read FGetTokenEvent Write FGetTokenEvent;
204- Property Header : String Read FHeader;
205- Property PayLoad : String Read FPayLoad Write FPayLoad;
206- Property Signature : String Read FSignature Write FSignature;
207- Property PublicKey : String Read FPublicKey Write FPublicKey;
208- Property PrivateKey : String Read FPrivateKey Write FPrivateKey;
209- Property RedirectURI : String Read FRedirectURI Write FRedirectURI;
161+ property TokenType: TRESTDWAuthOptionTypes read FTokenType write FTokenType;
162+ property AutoBuildHex: Boolean read FAutoBuildHex write FAutoBuildHex;
163+ property Token: String read FToken write FToken;
164+ property GrantCodeEvent: String read FGrantCodeEvent write FGrantCodeEvent;
165+ property GrantType: String read FGrantType write FGrantType;
166+ property GetTokenEvent: String read FGetTokenEvent write FGetTokenEvent;
167+ property ClientID: String read FClientID write FClientID;
168+ property ClientSecret: String read FClientSecret write FClientSecret;
169+ property RedirectURI: String read FRedirectURI write FRedirectURI;
170+ property ExpiresIn: TDateTime read FExpiresIn;
210171 end ;
211172
212173 TOnUserBasicAuth = Procedure(Welcomemsg, AccessTag,
@@ -216,14 +177,14 @@ TRESTDWAuthToken = class(TRESTDWServerAuthBase)
216177 Var ErrorMessage : String;
217178 Var Accept : Boolean) Of Object ;
218179
219- TOnGetToken = Procedure(Welcomemsg,
220- AccessTag : String;
221- Params : TRESTDWParams;
222- AuthOptions : TRESTDWAuthToken;
223- Var ErrorCode : Integer;
224- Var ErrorMessage : String;
225- Var TokenID : String;
226- Var Accept : Boolean) Of Object ;
180+ TOnGetToken = Procedure(Welcomemsg,
181+ AccessTag : String;
182+ Params : TRESTDWParams;
183+ AuthOptions : TRESTDWAuthToken;
184+ Var ErrorCode : Integer;
185+ Var ErrorMessage : String;
186+ Var TokenID : String;
187+ Var Accept : Boolean) Of Object ;
227188
228189 TOnUserTokenAuth = Procedure(Welcomemsg,
229190 AccessTag : String;
@@ -965,22 +926,7 @@ procedure TRESTDWAuthToken.SetToken(AValue: String);
965926
966927{ TRESTDWAuthOAuth }
967928
968- Function TRESTDWAuthOAuth.CreateSelfSignedCert_X509 (CertOptions : TRESTDWCertOptions;
969- Var Certificate,
970- PrivateKey : TRESTDWBytes) : Boolean;
971- begin
972- Result := TRESTDWOpenSSLHelper.CreateSelfSignedCert_X509(CertOptions.Country,
973- CertOptions.State,
974- CertOptions.Locality,
975- CertOptions.Organization,
976- CertOptions.OrgUnit,
977- CertOptions.CommonName,
978- CertOptions.ServerName,
979- CertOptions.ExpiresDays,
980- Certificate, PrivateKey);
981- End ;
982-
983- Function TRESTDWAuthOAuth.AuthValidate (ADataModuleRESTDW : TObject;
929+ Function TRESTDWAuthOAuth.AuthValidate (ADataModuleRESTDW : TObject;
984930 AUrlToExec,
985931 AWelcomeMessage,
986932 AAccessTag,
@@ -1004,24 +950,16 @@ procedure TRESTDWAuthToken.SetToken(AValue: String);
1004950Constructor TRESTDWAuthOAuth.Create(aOwner: TComponent);
1005951Begin
1006952 Inherited ;
1007- FRSASHA256_Validation := True;
1008- FServerValidationCert := True;
1009- FToken := ' ' ;
1010- FRedirectURI := ' ' ;
1011- FGrantType := ' client_credentials' ;
1012- FGetTokenEvent := ' access-token' ;
1013- FGrantCodeEvent := ' authorize' ;
1014- FHeader := ' {"alg": "RS256", "typ": "JWT"}' ;
1015- FLifeCycle := 1800 ; // 30 Minutos
1016- FPayLoad := ' ' ;
1017- FSignature := ' ' ;
1018- FPublicKey := ' ' ;
1019- FPrivateKey := ' ' ;
1020- FRedirectURI := ' ' ;
1021- FBeginTime := 0 ;
1022- FEndTime := 0 ;
1023- FAutoBuildHex := False;
1024- FTokenType := rdwOATBasic;
953+ FClientID := ' ' ;
954+ FClientSecret := ' ' ;
955+ FToken := ' ' ;
956+ FRedirectURI := ' ' ;
957+ FGrantType := ' client_credentials' ;
958+ FGetTokenEvent := ' access-token' ;
959+ FGrantCodeEvent := ' authorize' ;
960+ FAutoBuildHex := False;
961+ FExpiresIn := 0 ;
962+ FTokenType := rdwOATBasic;
1025963End ;
1026964
1027965{ TRESTDWAuthenticatorBase }
0 commit comments