Repository navigation
Conversation
Add Application::decorate_logon, called for every outbound Logon after the standard header fields and the Logon's own fields are set, and before the message is encoded, persisted and sent. Counterparties that authenticate in the Logon (Username/Password, or a signature over the header fields in RawData) can add those fields here. An error refuses the Logon: nothing is persisted or sent and no sequence number is consumed, so a Logon that cannot be authenticated is never sent without its credentials.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Some FIX venues authenticate in the Logon itself: the initiator must add credentials such as Username(553) and Password(554), or an HMAC signature over header fields (for example SendingTime, MsgSeqNum, SenderCompID and TargetCompID) carried in RawDataLength(95)/RawData(96). The signature depends on the final MsgSeqNum and SendingTime, so it can only be computed once the engine has built the Logon. Today the Logon is built from configuration alone and there is no hook to add these fields.
Change
Application::decorate_logon(&self, logon: &mut Message) -> Result<(), LogonDecorationError>, a synchronous method with a default that leaves the Logon unchanged, so existing applications are unaffected.SendError::LogonRefused/ an internalLogonRefusedsend error.generate_messageis split intobuild_message(header plus body, unencoded) and the encode step, andSessionCtx::prepare_logonshares the increment-then-persist tail withprepare_message. Sequence-number and store semantics are unchanged for every other message.Tests
test_logon_is_decorated_by_application: the decorator reads the header's MsgSeqNum and adds Password(554); the counterparty receives the decorated Logon and the session becomes active.test_logon_refused_by_application_is_not_sent: a refusing decorator leaves the session in AwaitingLogon with the next sender sequence number still 1, and the counterparty is disconnected at the logon timeout without ever receiving a message.The fake application gains a
logon_decorator_fnbuilder option for these tests.I could not build this workspace locally, so I am relying on CI for the compile, clippy and test run.
Note on logging
The writer logs every outbound message at debug level, so credentials added by a decorator appear in debug logs. We redact Password, Username and RawData in our own deployment; if you would like that upstream, I am happy to follow up with a separate PR for a configurable list of tags to mask in message logging.
This contribution is offered under the project's MIT licence.