ONE ACCOUNT PER MAILBOX, and the account name IS the mailbox address. That is the whole data model, and it lines up with the other two things a mailbox has: its client certificate (bound to the same address by StreamSec.Mail.SMTPServer) and its maildir (StreamSec.Mail.SMTPDelivery). WHY THIS EXISTS. SMTP AUTH PLAIN and LOGIN send the password itself, so the server has to be able to VERIFY one - which means storing something derived from it. TsmCustomSMTPServer.OnAuthenticate deliberately denies by default and leaves that to the application; this component is the shipped answer. WHAT IS STORED IS NOT THE PASSWORD. Each account holds an Argon2id verifier (RFC 9106) over a per-account random salt, with the cost parameters recorded ALONGSIDE it. Recording them per account is what makes the store upgradable: raise MemoryKiB or Iterations later and existing accounts still verify with the parameters they were written with, then get silently re-derived at their next successful sign-in (see UpgradeOnVerify). A store whose cost cannot be raised without invalidating every password is a store that never gets raised. COMPARISON IS CONSTANT TIME (EqualMemConstantTime). The margin is smaller here than for a MAC tag - an attacker does not choose the verifier, only the password behind it - but the library has one rule about comparing secrets and this follows it rather than arguing about the exception. THE FILE IS THE STORE. There is no design-time user collection, deliberately: a published collection would put password verifiers in a DFM, where they get copied into version control and shipped inside an executable. Provision at run time, or edit the file. IT IS NOT A DIRECTORY. No groups, no aliases, no quotas. An account either exists and can authenticate, or it does not.
Feature notes: Mail subsystem notes (SMTP / POP3 / IMAP)
inherits from Exception
(no public members)
One account. Held only in memory and in the file - it is not a TCollectionItem and cannot be streamed into a DFM, which is deliberate.
destructor Destroy; override;
property Mailbox: string read fMailbox;
property Enabled: Boolean read fEnabled write fEnabled;
property Failures: Integer read fFailures;
property LastFailure: TDateTime read fLastFailure;
property Created: TDateTime read fCreated;
property MemoryKiB: Integer read fMemoryKiB;
property Iterations: Integer read fIterations;
property Parallelism: Integer read fParallelism;
inherits from TComponent
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetPassword(const aMailbox: string; const aPassword: iSecretKey); overload;
procedure SetPassword(const aMailbox, aPassword: string); overload;
function DeleteUser(const aMailbox: string): Boolean;
function UserExists(const aMailbox: string): Boolean;
procedure SetEnabled(const aMailbox: string; aEnabled: Boolean);
procedure Unlock(const aMailbox: string);
function Verify(const aMailbox: string; const aPassword: iSecretKey): Boolean; overload;
function VerifyEx(const aMailbox: string; const aPassword: iSecretKey): tMailUserResult; overload;
function Verify(const aMailbox: string; const aPassword: iSecretKey; const aSource: string): Boolean; overload;
function VerifyEx(const aMailbox: string; const aPassword: iSecretKey; const aSource: string): tMailUserResult; overload;
function IsLocked(const aMailbox: string): Boolean; overload;
function IsLocked(const aMailbox, aSource: string): Boolean; overload;
function FailureEntryCount: Integer;
function IsEnabled(const aMailbox: string): Boolean;
procedure LoadFromFile;
procedure SaveToFile;
procedure Clear;
function MailboxNames: TArray<string>;
function Count: Integer;
property FileName: string read fFileName write SetFileName;
property AutoSave: Boolean read fAutoSave write fAutoSave default True;
property UpgradeOnVerify: Boolean read fUpgradeOnVerify write fUpgradeOnVerify default True;
property MemoryKiB: Integer read fMemoryKiB write SetMemoryKiB default cMailUserMemoryKiB;
property Iterations: Integer read fIterations write SetIterations default cMailUserIterations;
property Parallelism: Integer read fParallelism write SetParallelism default cMailUserParallelism;
property MaxFailures: Integer read fMaxFailures write SetMaxFailures default cMailUserMaxFailures;
property LockoutSeconds: Integer read fLockoutSeconds write SetLockoutSeconds default cMailUserLockSeconds;
property MaxFailureEntries: Integer read fMaxFailureEntries write SetMaxFailureEntries default cMailUserFailureEntries;
property OnUserChanged: tMailUsersChangeEvent read fOnUserChanged write fOnUserChanged;
Why an authentication attempt did not succeed. Returned rather than merely False so a deployment can log the difference - but see the note on Verify: the SMTP layer must not tell the CLIENT which of these it was.