OnixS C++ FIX Engine 4.14.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Logon Password Authentication

While Accepting an incoming FIX connection, additional authentication checks may be required. The typical checks are Logon username/password and source IP address.

The required authentication logic could be added to the OnixS::FIX::ISessionListener::onInboundSessionMsg(..) method. If the authentication fails and the FIX connection needs to be rejected (closed) then the std::runtime_error exception (or the derived one) should be thrown.

For example:

bool doAuthentication(const Message& , std::string& )
{
// Perform some authentication.
return true;
}
class SessionListener : public ISessionListener
{
public:
void onInboundSessionMsg(Message& message, Session*) override
{
if (message.type() == OnixS::FIX::FIX40::Values::MsgType::Logon)
{
std::string reason;
// Do user authentication here
if (!doAuthentication(message, reason))
{
throw std::runtime_error(reason);
}
}
}
};

If the std::runtime_error exception is thrown and OnixS::FIX::EngineSettings::sendLogoutOnException(..) or OnixS::FIX::Session::sendLogoutOnException(..) is set to true then the Logout FIX message will be sent before closing the FIX connection. Otherwise, the connection will be closed immediately.