Skip to content

Commit 50f2ce5

Browse files
author
Arnaud Bouchez
committed
ex: fixed TBO samples
1 parent 3cc6400 commit 50f2ce5

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

ex/ThirdPartyDemos/tbo/02-Zip-AES-Pictures/frm_Main.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ constructor TImageResourceFile.Create(const pmcFileName: TFileName; const pmcPas
9696

9797
destructor TImageResourceFile.Destroy;
9898
begin
99-
FillZero(FPassword);
99+
FillZero(RawByteString(FPassword));
100100
inherited Destroy;
101101
end;
102102

ex/ThirdPartyDemos/tbo/03-HttpServer-MethodServices/TestRestServer.dpr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ uses
2121
mormot.core.search,
2222
mormot.core.buffers,
2323
mormot.core.unicode,
24+
mormot.crypt.secure,
2425
mormot.orm.base,
2526
mormot.orm.core,
2627
mormot.rest.core,
@@ -145,8 +146,7 @@ begin
145146
if not FileExists(pmcFileName) then Exit; //=>
146147

147148
json := AnyTextFileToRawUtf8(pmcFileName, {AssumeUtf8IfNoBom=} True);
148-
if IsValidJson(json)
149-
and (DynArrayLoadJson(customers, Pointer(json), TypeInfo(TCustomerItemArray)) <> Nil) then
149+
if DynArrayLoadJson(customers, json, TypeInfo(TCustomerItemArray)) then
150150
begin
151151
var authUser: TFileAuthUser := TFileAuthUser.Create;
152152
try
@@ -158,7 +158,8 @@ begin
158158
authUser.CustomerNum := customers[i].CustomerNum;
159159
authUser.LogonName := customers[i].LoginUserName;
160160
// Never work with passwords in plain text, this also applies to saving! Therefore, this is not a good example.
161-
authUser.PasswordHashHexa := TAuthUser.ComputeHashedPassword(customers[i].LoginPassword);
161+
authUser.PasswordPlain := customers[i].LoginPassword;
162+
// consider using SCRAM-MCF with authUser.SetPassword(..., mcfSha256Crypt) here
162163
authUser.DisplayName := StringToUtf8(Format('Customer number: %d', [customers[i].CustomerNum]));
163164
authUser.GroupRights := TAuthGroup(3); // AuthGroup: User
164165
Server.Add(authUser, True);

ex/ThirdPartyDemos/tbo/04-HttpServer-InterfaceServices/frm_Main.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ procedure TfrmMain.ExecuteConnectServerInternal(const pmcUserName, pmcPassword:
226226
begin
227227
if FDocumentService.Client.ServerTimeStampSynchronize then
228228
begin
229-
if FDocumentService.Client.SetUser(pmcUserName, TAuthUser.ComputeHashedPassword(pmcPassword), True) then
229+
if FDocumentService.Client.SetUser(pmcUserName, pmcPassword) then
230230
begin
231231
if FDocumentService.InitializeServices then
232232
scsCode := scsOk

ex/ThirdPartyDemos/tbo/04-HttpServer-InterfaceServices/u_ServiceServer.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ function TFileRestServer.InitAuthForAllCustomers(const pmcFileName: TFileName):
114114
if not FileExists(pmcFileName) then Exit; //=>
115115

116116
json := AnyTextFileToRawUtf8(pmcFileName, {AssumeUtf8IfNoBom=} True);
117-
if IsValidJson(json)
118-
and (DynArrayLoadJson(customers, Pointer(json), TypeInfo(TCustomerItemArray)) <> Nil) then
117+
if DynArrayLoadJson(customers, json, TypeInfo(TCustomerItemArray)) then
119118
begin
120119
var authUser: TFileAuthUser := TFileAuthUser.Create;
121120
try
@@ -127,7 +126,8 @@ function TFileRestServer.InitAuthForAllCustomers(const pmcFileName: TFileName):
127126
authUser.CustomerNum := customers[i].CustomerNum;
128127
authUser.LogonName := customers[i].LoginUserName;
129128
// Never work with passwords in plain text, this also applies to saving! Therefore, this is not a good example.
130-
authUser.PasswordHashHexa := TAuthUser.ComputeHashedPassword(customers[i].LoginPassword);
129+
authUser.PasswordPlain := customers[i].LoginPassword;
130+
// consider using SCRAM-MCF with authUser.SetPassword(..., mcfSha256Crypt) here
131131
authUser.DisplayName := StringToUtf8(Format('Customer number: %d', [customers[i].CustomerNum]));
132132
authUser.GroupRights := TAuthGroup(3); // AuthGroup: User
133133
Server.Add(authUser, True);

ex/ThirdPartyDemos/tbo/05-WebMustache/u_FileServer.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ function TFileServer.DoZipFileRequest(pmCtxt: THttpServerRequestAbstract; const
267267
if Length(rawFileContent) > 0 then
268268
begin
269269
pmCtxt.OutContent := rawFileContent;
270-
pmCtxt.OutContentType := GetMimeContentType(Pointer(rawFileContent), Length(rawFileContent), Utf8ToString(contentFile));
270+
pmCtxt.OutContentType := GetMimeContentType(rawFileContent, Utf8ToString(contentFile));
271271
pmCtxt.OutCustomHeaders := HEADER_CONTENT_TYPE + pmCtxt.OutContentType;
272272
Result := HTTP_SUCCESS;
273273
end;
@@ -295,7 +295,7 @@ function TFileServer.SplitUrlSchemePathAndQuery(const pmcUrl: RawUtf8; out pmoUr
295295
urlQuery: PUtf8Char;
296296
urlPathLen: Integer;
297297
begin
298-
p := PUtf8Char(Pointer(pmcUrl));
298+
p := pointer(pmcUrl);
299299
if (p <> Nil) and (p^ = '/') then
300300
Inc(p)
301301
else

src/mormot.commit.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.3.13055'
1+
'2.3.13056'

0 commit comments

Comments
 (0)