1

Im trying to understand the data flow of ejabberd and having a hard time till now.

First, these are the modules Im working on: ejabberd_c2s, ejabberd_auth, ejabberd_sm, ejabberd_sm_mnesia.

I understand that ejabberd_c2s is a gen_fsm that is entry point for any client that wants to talk to any other client.

Dataflow: When a client connects to ejabberd_c2s, it sends some data, not sure exactly what but along the lines of {JID}. But not able to figure out how ejabberd_c2s authenticates? Where does it actually call the authentication module and if the authentication is successful, who creates a session for that user? is it ejabberd_c2s or ejabberd_auth ?

I understand that ejabberd_sm[_mnesia] are the api calls that will actually create a session for anyone.

References to code/ samples is highly appreciated.!

How exactly this whole thing works?

Thanks a lot!

sad
  • 820
  • 1
  • 9
  • 16

1 Answers1

1

Authentication is primarily made is wait_for_stream function of c2s: https://github.com/processone/ejabberd/blob/master/src/ejabberd_c2s.erl#L348

Session is created in wait_for_bind function of c2s: https://github.com/processone/ejabberd/blob/master/src/ejabberd_c2s.erl#L1046

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
  • Thanks. what does wait_for_auth do? https://github.com/processone/ejabberd/blob/master/src/ejabberd_c2s.erl#L574 also, there are many places where auth_module is used, for eg, in wait_for_auth, wait_for_sasl etc. how are they different from one in wait_for_stream ? A – sad Jun 02 '16 at 07:10
  • Depends on XMPP protocol version and type of authentication. Generally, it is not the one used. – Mickaël Rémond Jun 03 '16 at 06:50