{"id":31710148,"url":"https://github.com/emqx/emqx-auth-mongo","last_synced_at":"2025-10-09T00:11:20.665Z","repository":{"id":46126977,"uuid":"43938773","full_name":"emqx/emqx-auth-mongo","owner":"emqx","description":"EMQX Authentication/ACL with MongoDB","archived":false,"fork":false,"pushed_at":"2023-12-27T07:37:24.000Z","size":414,"stargazers_count":21,"open_issues_count":15,"forks_count":26,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-09-29T22:58:33.267Z","etag":null,"topics":["acl","authentication","emqx","emqx-plugin","mongodb"],"latest_commit_sha":null,"homepage":"https://emqx.io/","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emqx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-09T07:07:31.000Z","updated_at":"2023-12-27T07:37:34.000Z","dependencies_parsed_at":"2022-08-30T09:21:09.154Z","dependency_job_id":null,"html_url":"https://github.com/emqx/emqx-auth-mongo","commit_stats":null,"previous_names":[],"tags_count":100,"template":false,"template_full_name":null,"purl":"pkg:github/emqx/emqx-auth-mongo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Femqx-auth-mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Femqx-auth-mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Femqx-auth-mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Femqx-auth-mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emqx","download_url":"https://codeload.github.com/emqx/emqx-auth-mongo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emqx%2Femqx-auth-mongo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000745,"owners_count":26082879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acl","authentication","emqx","emqx-plugin","mongodb"],"created_at":"2025-10-09T00:10:25.481Z","updated_at":"2025-10-09T00:11:20.660Z","avatar_url":"https://github.com/emqx.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"emqx_auth_mongo\n===============\n\nEMQX Authentication/ACL with MongoDB\n\nBuild the Plugin\n----------------\n\n```\nmake \u0026 make tests\n```\n\nConfiguration\n-------------\n\nFile: etc/emqx_auth_mongo.conf\n\n```\n## MongoDB Topology Type.\n##\n## Value: single | unknown | sharded | rs\nauth.mongo.type = single\n\n## Sets the set name if type is rs.\n##\n## Value: String\n## auth.mongo.rs_set_name =\n\n## MongoDB server list.\n##\n## Value: String\n##\n## Examples: 127.0.0.1:27017,127.0.0.2:27017...\nauth.mongo.server = 127.0.0.1:27017\n\n## MongoDB pool size\n##\n## Value: Number\nauth.mongo.pool = 8\n\n## MongoDB login user.\n##\n## Value: String\n## auth.mongo.login =\n\n## MongoDB password.\n##\n## Value: String\n## auth.mongo.password =\n\n## MongoDB AuthSource\n##\n## Value: String\n## Default: mqtt\n## auth.mongo.auth_source = admin\n\n## MongoDB database\n##\n## Value: String\nauth.mongo.database = mqtt\n\n## MongoDB write mode.\n##\n## Value: unsafe | safe\n## auth.mongo.w_mode =\n\n## Mongo read mode.\n##\n## Value: master | slave_ok\n## auth.mongo.r_mode =\n\n## MongoDB topology options.\nauth.mongo.topology.pool_size = 1\nauth.mongo.topology.max_overflow = 0\n## auth.mongo.topology.overflow_ttl = 1000\n## auth.mongo.topology.overflow_check_period = 1000\n## auth.mongo.topology.local_threshold_ms = 1000\n## auth.mongo.topology.connect_timeout_ms = 20000\n## auth.mongo.topology.socket_timeout_ms = 100\n## auth.mongo.topology.server_selection_timeout_ms = 30000\n## auth.mongo.topology.wait_queue_timeout_ms = 1000\n## auth.mongo.topology.heartbeat_frequency_ms = 10000\n## auth.mongo.topology.min_heartbeat_frequency_ms = 1000\n\n## Authentication query.\nauth.mongo.auth_query.collection = mqtt_user\n\nauth.mongo.auth_query.password_field = password\n\n## Password hash.\n##\n## Value: plain | md5 | sha | sha256 | bcrypt\nauth.mongo.auth_query.password_hash = sha256\n\n## sha256 with salt suffix\n## auth.mongo.auth_query.password_hash = sha256,salt\n\n## sha256 with salt prefix\n## auth.mongo.auth_query.password_hash = salt,sha256\n\n## bcrypt with salt prefix\n## auth.mongo.auth_query.password_hash = salt,bcrypt\n\n## pbkdf2 with macfun iterations dklen\n## macfun: md4, md5, ripemd160, sha, sha224, sha256, sha384, sha512\n## auth.mongo.auth_query.password_hash = pbkdf2,sha256,1000,20\n\nauth.mongo.auth_query.selector = username=%u\n\n## Enable superuser query.\nauth.mongo.super_query = on\n\nauth.mongo.super_query.collection = mqtt_user\n\nauth.mongo.super_query.super_field = is_superuser\n\nauth.mongo.super_query.selector = username=%u\n\n## Enable ACL query.\nauth.mongo.acl_query = on\n\nauth.mongo.acl_query.collection = mqtt_acl\n\nauth.mongo.acl_query.selector = username=%u\n```\n\nLoad the Plugin\n---------------\n\n```\n./bin/emqx_ctl plugins load emqx_auth_mongo\n```\n\nMongoDB Database\n----------------\n\n```\nuse mqtt\ndb.createCollection(\"mqtt_user\")\ndb.createCollection(\"mqtt_acl\")\ndb.mqtt_user.ensureIndex({\"username\":1})\n```\n\nmqtt_user Collection\n--------------------\n\n```\n{\n    username: \"user\",\n    password: \"password hash\",\n    salt: \"password salt\",\n    is_superuser: boolean (true, false),\n    created: \"datetime\"\n}\n```\n\nFor example:\n```\ndb.mqtt_user.insert({username: \"test\", password: \"password hash\", salt: \"password salt\", is_superuser: false})\ndb.mqtt_user.insert({username: \"root\", is_superuser: true})\n```\n\nmqtt_acl Collection\n-------------------\n\n```\n{\n    username: \"username\",\n    clientid: \"clientid\",\n    publish: [\"topic1\", \"topic2\", ...],\n    subscribe: [\"subtop1\", \"subtop2\", ...],\n    pubsub: [\"topic/#\", \"topic1\", ...]\n}\n```\n\nFor example:\n\n```\ndb.mqtt_acl.insert({username: \"test\", publish: [\"t/1\", \"t/2\"], subscribe: [\"user/%u\", \"client/%c\"]})\ndb.mqtt_acl.insert({username: \"admin\", pubsub: [\"#\"]})\n```\n\nLicense\n-------\n\nApache License Version 2.0\n\nAuthor\n------\n\nEMQX Team.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femqx%2Femqx-auth-mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femqx%2Femqx-auth-mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femqx%2Femqx-auth-mongo/lists"}