processone/ejabberd-contrib

Ejabberd 20.07 ejabberd_auth_http fails to load

jdsumsion opened this issue · 4 comments

According to #284, it sounded like ejabberd_auth_http should be working, but I'm having issues getting it to load

Environment

Ejabberd: 20.07
Erlang: Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:1]
Installed from: Official Docker image

Steps to reproduce

  1. ejabberdctl modules_update_specs
  2. ejabberdctl module_install ejabberd_http_auth
  3. Add config to conf/ejabberd.yml
auth_method: http
auth_opts:
  host: "http://localhost:5000"
  connection_pool_size: 10
  connection_opts: []
  basic_auth: ""
  path_prefix: "/"
  1. Error from error.log
2020-11-06 00:32:33.408767+00:00 [critical] <0.1170.0>@ejabberd_app:start/2:71 Failed to start ejabberd application: Invalid value of option auth_method->1: unsupported database: http
  1. Set config to auth_method: ejabberd_auth_http fails in the same way with unsupported database

Looking in src/ejabberd_options.erl I can see:

opt_type(auth_method) ->
    econf:list_or_single(econf:db_type(ejabberd_auth));

which is apparently just a type check.

Here is the contents of my modules directory:

~ $ find ~/.ejabberd-modules/ | grep -v sources
/home/ejabberd/.ejabberd-modules/
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ejabberd_auth_http.spec
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/priv
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/priv/fusco_drv.so
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/cuesport.beam
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/fusco_cp.beam
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/fusco_lib.beam
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/fusco_binary.beam
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/fusco_protocol.beam
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/scram2.beam
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/ejabberd_auth_http.beam
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/fusco_sock.beam
/home/ejabberd/.ejabberd-modules/ejabberd_auth_http/ebin/fusco.beam

I've tried building 20.03 and the untagged revision 73dbd34f95f3959b8ffb08cf2699e1bca941af58 from HEAD ejabberd with the same results.

Confirmed that ejabberd_auth_http.erl has the following line:

-behaviour(ejabberd_auth).

Seems like the ejabberd_auth_http module isn't loading properly so that it can be checked against the ejabberd_auth type.

As a last ditch effort, I tried adding ejabberd_auth_http: {} under modules: but that didn't work because it apparently isn't a standalone module, it complained about not having a start/2 function.

How do I get the ejabberd_auth_http special module loaded so that it can be used?

Your steps from 1 to 3 are quite good, it should work and not show the error of step 4.

This is how I try it, and works correctly:

$ sudo docker pull ejabberd/ecs:20.07
20.07: Pulling from ejabberd/ecs
c9b1b535fdd9: Pull complete 
c50d7f2eede5: Pull complete 
f00b4c6d5dbf: Pull complete 
1275b3ae010e: Pull complete 
4e4ef80aa2b8: Pull complete 
fb64b13d7b5a: Pull complete 
8a54b4956f0f: Pull complete 
Digest: sha256:cd50fbec8f71e320412f4a4b44e0a57cb7cbb4b6c4b42ef4d31534f8abf5e4f6
Status: Downloaded newer image for ejabberd/ecs:20.07

$ sudo docker run --name elive -it -p 5222:5222 -p 5280:5280 ejabberd/ecs:20.07 live

Then in another console:

$ sudo docker exec -it elive sh
$ ./bin/ejabberdctl modules_update_specs
$ ./bin/ejabberdctl module_install ejabberd_auth_http
/home/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/deps/fusco/src/fusco.erl:573: Warning: erlang:get_stacktrace/0: deprecated; use the new try/catch syntax for retrieving the stack backtrace
/home/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl:139: Warning: variable 'Server' is unused
/home/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl:139: Warning: variable 'User' is unused
/home/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/ejabberd_auth_http/src/ejabberd_auth_http.erl:164: Warning: variable 'Error' is unused
$ vi conf/ejabberd.yml

Or instead of vi, use any other text editor, and add to the end of the file the same options that you mentioned in step 3. Finally, reload the configuration:

$ ./bin/ejabberdctl reload_config

Thank you for your response!

I will try putting the config at the end of the file and see if that makes a difference.

And I'll follow your instructions exactly, maybe I messed something up in how I launched the docker.

The position in ejabberd.yml was the problem, thank you so much! If you put it at the end of the file it works great.

Thanks for your earlier maintenance work on this module! It is key to making ejabberd work for our current use case.