ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

"Azure AD App Setup" table and DataPerCompany problem

Open demiliani opened this issue 5 years ago • 2 comments

Table 6300 "Azure AD App Setup" is defined as DataPerCompany = false and it has the following field:

field(5; "Isolated Storage Secret Key"; Guid)
    {
        Caption = 'Isolated Storage Secret Key';
    }

Then it has the following methods for inserting and reading the secret key:

[NonDebuggable]
[Scope('OnPrem')]
procedure GetSecretKeyFromIsolatedStorage() SecretKey: Text
begin
    if not IsNullGuid("Isolated Storage Secret Key") then
        if not IsolatedStorage.Get("Isolated Storage Secret Key", DataScope::Company, SecretKey) then;

    exit(SecretKey);
end;

[NonDebuggable]
[Scope('OnPrem')]
procedure SetSecretKeyToIsolatedStorage(SecretKey: Text)
var
    NewSecretGuid: Guid;
begin
    if not IsNullGuid("Isolated Storage Secret Key") then
        if not IsolatedStorage.Delete("Isolated Storage Secret Key", DataScope::Company) then;

    NewSecretGuid := CreateGuid();

    if (not EncryptionEnabled() or (StrLen(SecretKey) > 215)) then
        IsolatedStorage.Set(NewSecretGuid, SecretKey, DataScope::Company)
    else
        IsolatedStorage.SetEncrypted(NewSecretGuid, SecretKey, DataScope::Company);

    Rec."Isolated Storage Secret Key" := NewSecretGuid;
end;

These methods for setting/getting the secret key save a data into the IsolatedStorage with DataScope::Company and this is not compatible with the DataPerCompany = false property of the table. If you switch company, the previous secret key is lost.

demiliani avatar Sep 06 '21 14:09 demiliani

Hi @demiliani ,

Thanks this is a good find, we already have made a fix which will be delivered with all the next onprem updates that are affected.

PaulIvan avatar Sep 08 '21 07:09 PaulIvan

Thanks :)

demiliani avatar Sep 08 '21 07:09 demiliani