Building the Mosquitto-Auth plugin on MAC

Mosquitto-auth plugin is a plugin to authenticate and authorize Mosquitto users from one of several distinct back-ends.


This is a continuation from my previous post, where I talk about getting Mosquitto on a MAC. So, this post assumes that the system has OpenSSL installed. 
The location of the Mosquitto-auth plug-in is here:

https://github.com/jpmens/mosquitto-auth-plug/

To clone the repository:

git clone https://github.com/jpmens/mosquitto-auth-plug.git

For the make to succeed, it is necessary to correct OSSLIBS in the config file.
To this end, copy config.mk.in to config.mk

cp config.mk.in config.mk

And then I edited the config.mk using vi, making sure the lines for OSSLIBS, and auth-plug.so read as following:

OSSLIBS = -L$(OPENSSLDIR)/lib -lssl -lcrypto

auth-plug.so : $(OBJS) $(BE_DEPS)
        $(CC) $(CFLAGS) $(LDFLAGS) -fPIC -shared -undefined dynamic_lookup -o $@ $(OBJS) $(BE_DEPS) $(LDADD)

With these changes, the make succeeded. For the plugin to work properly,  I used OTOOL to correct dynamic library locations (described in my earlier post).

Then, in the mosquitto folder, it is necessary to change the mosquitto.conf so that mosquitto knows where to find the plugin. I also added some configuration information - defining the backend as http, giving IP as the localhost, identifying a port number, and gave the relative URIs. This information is necessary for the plugin not to complain about missing information. 


auth_plugin /Users/cigdem/Development/mqtt-trials/mosquitto/src/auth-plug.so
auth_opt_backends http
auth_opt_http_ip 127.0.0.1
auth_opt_http_port 3001
#auth_opt_http_hostname
auth_opt_http_getuser_uri /user
auth_opt_http_aclcheck_uri /acl
#auth_opt_http_with_tls true
auth_opt_http_superuser_uri /super_user

Then, to test whether this runs:

mosquitto -c /path/to/mosquitto.conf


Comments