
My company has a policy for secret key rotations every month.
Is it possible to configure Syncovery to fetch the secret key from a file?
Thanks in advance!
Dean.

Hi.tobias wrote: Thu Nov 10, 2022 9:02 am Hello,
yes, it can be read from a text file using a PascalScript, please see
https://www.syncovery.com/pascalscript/
I hope I can write an example tomorrow.
Code: Select all
const cTextFilePath='C:\code19\X.txt';
function OnGetProfilePathBeforeListing(const isRightSide:Boolean;
var Path,UserName,Password:UnicodeString;
var AuthKey,AuthKeyPassword:AnsiString;
var Port:Integer):Boolean;
var F:Opaque;
NewPass:UnicodeString;
begin
if Copy(Path,1,5)='S3://' then begin
F:=OpenTextFile(cTextFilePath);
if F<>0 then begin
NewPass:=ReadLine(F);
CloseFile(F);
if (NewPass<>'') and (NewPass<>Password) then begin
Password:=NewPass;
if isRightSide then
SetProfileProperty('RightPassword',NewPass)
else
SetProfileProperty('LeftPassword',NewPass);
SaveProfileSettings;
end;
end;
end;
Result:=true;
end;
Code: Select all
const cTextFilePath='C:\code19\X.txt';
function OnGetProfilePathBeforeListing(const isRightSide:Boolean;
var Path,UserName,Password:UnicodeString;
var AuthKey,AuthKeyPassword:AnsiString;
var Port:Integer):Boolean;
var F:Opaque;
NewAccessID, NewSecretKey:UnicodeString;
begin
if Copy(Path,1,5)='S3://' then begin
F:=OpenTextFile(cTextFilePath);
if F<>0 then begin
NewAccessID:=ReadLine(F);
NewSecretKey:=ReadLine(F); // Read the second line for the Secret Key
CloseFile(F);
if (NewAccessID<>'') and (NewSecretKey<>'') then begin
// Check and update Access ID
if NewAccessID<>AuthKey then begin
AuthKey:=NewAccessID;
if isRightSide then
SetProfileProperty('RightAuthKey',NewAccessID)
else
SetProfileProperty('LeftAuthKey',NewAccessID);
SaveProfileSettings;
end;
// Check and update Secret Key
if NewSecretKey<>AuthKeyPassword then begin
AuthKeyPassword:=NewSecretKey;
if isRightSide then
SetProfileProperty('RightAuthKeyPassword',NewSecretKey)
else
SetProfileProperty('LeftAuthKeyPassword',NewSecretKey);
SaveProfileSettings;
end;
end;
end;
end;
Result:=true;
end;Code: Select all
const cTextFilePath='X:\Win64\AWSAccessKeys\s3-user.txt';
function OnGetProfilePathBeforeListing(const isRightSide:Boolean;
var Path,UserName,Password:UnicodeString;
var AuthKey,AuthKeyPassword:AnsiString;
var Port:Integer):Boolean;
var F:Opaque;
NewAccessID, NewSecretKey:UnicodeString;
begin
if Copy(Path,1,5)='S3://' then begin
F:=OpenTextFile(cTextFilePath);
if F<>0 then begin
NewAccessID:=ReadLine(F);
NewSecretKey:=ReadLine(F); // Read the second line for the Secret Key
CloseFile(F);
if (NewAccessID<>'') and (NewSecretKey<>'') then begin
// Check and update Access ID
if NewAccessID<>AuthKey then begin
AuthKey:=NewAccessID;
if isRightSide then
SetProfileProperty('RightUser',NewAccessID)
else
SetProfileProperty('LeftUser',NewAccessID);
SaveProfileSettings;
end;
// Check and update Secret Key
if NewSecretKey<>AuthKeyPassword then begin
AuthKeyPassword:=NewSecretKey;
if isRightSide then
SetProfileProperty('RightPassword',NewSecretKey)
else
SetProfileProperty('LeftPassword',NewSecretKey);
SaveProfileSettings;
end;
end;
end;
end;
Result:=true;
end;Code: Select all
const cTextFilePath='X:\Win64\AWSAccessKeys\s3-user.txt';
function OnGetProfilePathBeforeListing(const isRightSide:Boolean;
var Path,UserName,Password:UnicodeString;
var AuthKey,AuthKeyPassword:AnsiString;
var Port:Integer):Boolean;
var F:Opaque;
NewAccessID, NewSecretKey:UnicodeString;
begin
if Copy(Path,1,5)='S3://' then begin
F:=OpenTextFile(cTextFilePath);
if F<>0 then begin
NewAccessID:=ReadLine(F);
NewSecretKey:=ReadLine(F); // Read the second line for the Secret Key
CloseFile(F);
if (NewAccessID<>'') and (NewSecretKey<>'') then begin
// Check and update Access ID
if NewAccessID<>UserName then begin
UserName:=NewAccessID;
if isRightSide then
SetProfileProperty('RightUser',NewAccessID)
else
SetProfileProperty('LeftUser',NewAccessID);
SaveProfileSettings;
end;
// Check and update Secret Key
if NewSecretKey<>Password then begin
Password:=NewSecretKey;
if isRightSide then
SetProfileProperty('RightPassword',NewSecretKey)
else
SetProfileProperty('LeftPassword',NewSecretKey);
SaveProfileSettings;
end;
end;
end;
end;
Result:=true;
end;