Skip to content

Add pluggable Logon authentication for custom FIX signers - #416

Closed
0-jake-0 wants to merge 1 commit into
mainfrom
claude/binance-io-adapter-kes-ugxsko
Closed

Add pluggable Logon authentication for custom FIX signers#416
0-jake-0 wants to merge 1 commit into
mainfrom
claude/binance-io-adapter-kes-ugxsko

Conversation

@0-jake-0

@0-jake-0 0-jake-0 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Extends FIX adapter to support custom authentication schemes beyond simple passwords. Introduces FixLogon enum and LogonContext to allow venues like Binance to attach cryptographic signatures (e.g., Ed25519) bound to the exact Logon message bytes on the wire.

Key Changes

  • New FixLogon enum with three variants:

    • None — no authentication fields (EncryptMethod/HeartBtInt/ResetSeqNumFlag only)
    • Password(String) — LMAX-style Username (tag 553) + Password (tag 554)
    • Custom(Arc<dyn Fn>) — caller-supplied builder for custom fields
  • New LogonContext struct passed to custom builders, exposing:

    • msg_type, sender_comp_id, target_comp_id (header fields)
    • msg_seq_num, sending_time (exact values the Logon carries)
    • Enables signers to compute payloads over the canonical wire format
  • Refactored message encoding:

    • SendingTime now formatted with millisecond precision (YYYYMMDD-HH:MM:SS.sss) to match venue requirements (e.g., Binance)
    • Extracted now_sending_time() helper to ensure consistent formatting
    • encode_message() takes sending_time parameter instead of computing it internally
  • New send_with() method on FixSession:

    • Computes sequence number and SendingTime once
    • Passes both to a builder closure so signers see exactly what goes on the wire
    • Prevents timing skew between signature computation and wire encoding
  • New public API:

    • fix_connect_tls_logon() — accepts FixLogon instead of Option<&str>
    • FixLogon::custom() — convenience constructor wrapping a builder in Arc
    • impl From<Option<&str>> for FixLogon — backward-compatible conversion
  • Updated FixThreadedSource to store FixLogon instead of Option<String>

  • Documentation in module-level comments and CLAUDE.md explaining the authentication flow and Binance Ed25519 example

Implementation Details

  • FixLogon is Clone to allow capture in closures passed to the session loop
  • Custom builders are Arc-wrapped to support Send + Sync across thread boundaries
  • FixSession::send_logon() uses send_with() to ensure the builder receives the exact sequence number and formatted time the Logon will carry
  • Backward compatibility maintained: fix_connect_tls(password: Option<&str>) now delegates to fix_connect_tls_logon() via FixLogon::from()
  • Test added (custom_logon_fields_are_sent) verifying custom fields are encoded and accessible in the wire message

Notes

  • Wingfoil remains venue/crypto-agnostic; Ed25519 implementation lives in the caller (e.g., the kes Binance adapter)
  • Millisecond precision in SendingTime is required by Binance and is now the standard for all venues

https://claude.ai/code/session_01Q96qpjaqcpywW3rdy1eHjW

The FIX adapter only supported LMAX-style Username/Password (tags 553/554)
in the Logon message. Venues like Binance authenticate with a signature
computed over the Logon header, which the fixed encoder couldn't express.

Add a generic `FixLogon` (None / Password / Custom) plus a `LogonContext`
carrying the SenderCompID, TargetCompID, MsgSeqNum and the exact SendingTime
string the Logon will carry. `FixSession::send_with` now computes the sequence
number and SendingTime once and hands both to the field builder and the
encoder, so a signer signs exactly what goes on the wire. SendingTime gains
millisecond precision.

`fix_connect_tls` is unchanged (delegates to a new `fix_connect_tls_logon`
that takes a `FixLogon`). wingfoil stays free of any venue/crypto specifics —
the Ed25519 signer lives in the caller.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q96qpjaqcpywW3rdy1eHjW

0-jake-0 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #418 (same commit; branch renamed to drop the venue name). Closing this one.


Generated by Claude Code

@0-jake-0 0-jake-0 closed this Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants