MongoDB authentication work flow at TCP level
10 Feb 2016In a personal project I’m looking at ways to manipulate authentication to a MongoDB at communication protocol level. MongoDB clients communicate with the database server using commands that are sent via a TCP/IP socket. Encoding of basic operations including UPDATE, INSERT, QUERY, GET_MORE and KILL_CURSORS are covered in MongoDB Wire Protocol. Authentication, on the other hand, is only described in the official manual at a rather high level. More details of authentication mechanisms are given in MongoDB authentication specifications, but again it’s not clear how authentication messages and commands are encoded at TCP level. After digging around MongoDB core driver with help of its author Christian Kvalheim, I got the flowchart below showing how authentication is done at a low level. Process in the flowchart are linked to source code of MongoDB core driver.