Code Monkey home page Code Monkey logo

ejabberd-module-guide's Introduction

The definitive guide to ejabberd modules

Starting with writing ejabberd modules was a real pain for me. There hasn't been much documentation around and most of the articles/blogposts are outdated. This guide should cover creating ejabberd modules from scratch with none or little experience in writing erlang. Previous experience in software development is required though.

Prerequisites

  • ejabberd installed on your local machine
  • erlang installed
  • git installed

Types of ejabberd modules

Authentication

Authentication modules make it possible to attach an external API or DB etc. to ejabberd in order to authenticate a user. There are various authentication modules already built-in and there's also the possibility to attach a script not written in erlang to authenticate (auth_method: external). This method is not recommended for high performance setups.

Hook-based

Hook-based modules allow you to interact with ejabberd based on hooks. It is for example possible to react on all message stanzas with own handlers.

Other

You can of course also add other modules to the ejabberd runtime which e.g. add a HTTP endpoint to ejabberd.

Basic module setup

I created a module setup which you can clone and use as a base for your own modules, just run:

$ git clone https://github.com/mweibel/ejabberd-module-bootstrap.git

And start fiddling.

Creating an authentication module

Clone the bootstrap into a directory

$ git clone https://github.com/mweibel/ejabberd-module-bootstrap.git example-auth && cd example-auth

Rename src/mod_example* to src/ejabberd_auth_example*.

$ mv src/mod_example.erl src/ejabberd_auth_example.erl
$ mv src/mod_example.app.src src/ejabberd_auth_example.app.src

Edit the src/ejabberd_auth_example.app.src to contain the following code:

{application, ejabberd_auth_example,
 [
  {vsn, git},
  {description, "Ejabberd authentication example"},
  {applications, [kernel, stdlib, ejabberd]},
  {registered, []},
  {env, []}
 ]}.

Now we're going to adapt the source code to do what we want in steps. First let's create the very basic code we need to have.

ejabberd-module-guide's People

Contributors

mweibel avatar

Stargazers

Siva avatar Ahmad Essam avatar Asha'man avatar Steven Livingstone-Perez avatar Zvi avatar R. Haluk Öngör avatar

Watchers

 avatar James Cloos avatar  avatar

ejabberd-module-guide's Issues

You didn't completed the article

The main thing is not clear to me is how do I compile the module and where should I put the module directory in order to compile it? What do I do with the .beam file, where should I put it etc.

Thanks

Still to complete?

Hi - this is a neat start. I'm fairly new to ejabberd and erlang but can follow along a bit. It looks like this has still to be finished - or perhaps the intention was only as an interface/contract example? I'm trying to auth against an external Postgres DB and want to use this approach.

Actually I need to unwrap a JWT and check the validity of this before auth'ing the users xmpp session but if i can get some kind of custom module auth working against an external db it would be a start.

Thanks for the sample!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.