ejabberd-contrib/mod_captcha_rust
Badlop f4ea11b0b6 Fix minor typos 2023-05-16 14:17:00 +02:00
..
conf mod_captcha_rust: New small module that uses Rust Captcha library 2023-01-04 13:38:08 +01:00
lib mod_captcha_rust: New small module that uses Rust Captcha library 2023-01-04 13:38:08 +01:00
COPYING mod_captcha_rust: New small module that uses Rust Captcha library 2023-01-04 13:38:08 +01:00
README.md Fix minor typos 2023-05-16 14:17:00 +02:00
mod_captcha_rust.spec mod_captcha_rust: New small module that uses Rust Captcha library 2023-01-04 13:38:08 +01:00

README.md

mod_captcha_rust - Generate CAPTCHAs using Rust library

Requires:

  • ejabberd 23.xx or higher compiled with Elixir
  • Erlang/OTP and Elixir to compile the captcha_nif Elixir library
  • Rust compiler (package rustc in some package managers)

This small module generates CAPTCHA images suitable for ejabberd's CAPTCHA feature, thanks to the captcha Elixir library, which internally uses the captcha Rust library.

See example CAPTCHA images in the captcha Rust documentation.

Get captcha_nif library

This module depends on an Elixir library, and there are two ways to get it installed, depending on how you obtained ejabberd:

A) ejabberd source code

If you compile ejabberd from source code, go to the path with your ejabberd source code and apply this small patch:

--- a/mix.exs
+++ b/mix.exs
@@ -99,6 +99,7 @@ defmodule Ejabberd.MixProject do
 
   defp deps do
     [{:base64url, "~> 1.0"},
+     {:captcha_nif, "~> 0.1", hex: :captcha_nif},
      {:cache_tab, "~> 1.0"},
      {:eimp, "~> 1.0"},
      {:ex_doc, ">= 0.0.0", only: :dev},

Then get the new dependencies, and compile as usual:

mix deps.get
make

Install ejabberd as usual, restart it and now you can proceed to install mod_captcha_rust.

B) ejabberd with binary installer

If you installed ejabberd using some kind of binary installer, you can download, compile and install the required library manually:

git clone https://github.com/feng19/captcha.git
cd captcha/
mix deps.get
mix
mix release

Copy all the directories from _build/dev/rel/captcha/lib to the path where you have ejabberd lib directories installed.

Now you can restart ejabberd and proceed to install mod_captcha_rust.

Basic Configuration

The minimal configuration required to get this module working is:

captcha_cmd: 'Elixir.ModCaptchaRust'

captcha_url: http://localhost:5280/captcha

listen:
  -
    port: 5280
    module: ejabberd_http
    request_handlers:
      /captcha: ejabberd_captcha

Options

This module supports those configurable options:

  • difficulty

    Sets the CAPTCHA difficulty, it can be easy, medium or hard. Default value: easy.

  • color

    Sets the CAPTCHA color, as a list of RGB integers from 0 to 255. Default value: [0, 0, 0].

Example of module configuration:

modules:
  'Elixir.ModCaptchaRust':
    difficulty: hard
    color: [255, 0, 0]