How to set up mosquitto-go-auth for postgresql in docker

Hi ,
I am trying to set up mosquitto-go-auth for postgresql and want to test end-to-end so mentioned below all the step what i have tried .
Gone through and tried to build docker image using docker-compose.yml which is there in repo.
In docker-compose.yml:

version: "3"



    image: postgres:9.0


      - psql:/var/lib/postgresql/data


      - 'POSTGRES_DB:appserver'

      - 'POSTGRES_USER:appserver'

      - 'POSTGRES_PASSWORD:appserver'


      - "5435:5432"


    image: iegomez/mosquitto-go-auth:0.5.0


      - ./conf:/etc/mosquitto


      - 1883:1883



And I have change in conf/go-auth.conf also.

auth_opt_log_level debug
auth_opt_backends files
auth_opt_check_prefix false

auth_opt_password_path /etc/mosquitto/auth/passwords
auth_opt_acl_path /etc/mosquitto/auth/acls

auth_opt_pg_host localhost
auth_opt_pg_port 5432
auth_opt_pg_dbname appserver
auth_opt_pg_user appserver
auth_opt_pg_password appserver
auth_opt_pg_userquery select password_hash from "user" where username = $1 and is_active = true limit 1 

In password:


I have mqtt_publish file which generally do the authentication , connect to the broker and publish on a topic .
In file:


But getting error like not able to authenticate .

time="2020-01-27T10:19:25Z" level=debug msg="checking auth cache for test"
time="2020-01-27T10:19:25Z" level=debug msg="checking user test with backend Files"
time="2020-01-27T10:19:25Z" level=warning msg="wrong password for user test\n"

Please help .

Hey, I think you may be mixing things up. From your post I take it that you generated the PBKDF2 password using the pw utility and stored it in a password for the files backend, but how does have to do with Postgres? Also, where’s that client.username_pw_set call coming from?

Hi iegomez,
Actually i want to set up mqtt broker with authentication layer where each client have to validate with their password and topics . This authentication things want to set up through postgresql DB not file based .
Regarding ‘client.username_pw_set’:
In mqtt client connection script this line will be there to check auth.
example :

client = paho.Client()
client.username_pw_set(“username”, “password”)

Ok, but what’s the issue here? How did you generate the password?