All Projects → emqx → emqx-auth-mysql

emqx / emqx-auth-mysql

Licence: Apache-2.0 license
Authentication, ACL with MySQL Database

Programming Languages

erlang
1774 projects
Makefile
30231 projects

Projects that are alternatives of or similar to emqx-auth-mysql

emqx-auth-http
EMQ X HTTP Authentication/ACL Plugin
Stars: ✭ 42 (-19.23%)
Mutual labels:  acl, emqx, emqx-plugin
emqx-auth-username
EMQ X Authentication with Username and Password
Stars: ✭ 16 (-69.23%)
Mutual labels:  emqx, emqx-plugin
emqx-lwm2m
EMQ X LwM2M Gateway
Stars: ✭ 29 (-44.23%)
Mutual labels:  emqx, emqx-plugin
Tor-IP-Addresses
Hourly checked and updated list of IP Addresses of Tor and Tor Exit Nodes
Stars: ✭ 182 (+250%)
Mutual labels:  acl
actix-casbin-auth
Casbin Actix-web access control middleware
Stars: ✭ 40 (-23.08%)
Mutual labels:  acl
sqlalchemy-adapter
SQLAlchemy Adapter for PyCasbin
Stars: ✭ 53 (+1.92%)
Mutual labels:  acl
opentab
开源的轻应用后端(Open Tiny App Backend),轻量,高效,易部署。
Stars: ✭ 27 (-48.08%)
Mutual labels:  acl
lua-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Lua (OpenResty)
Stars: ✭ 43 (-17.31%)
Mutual labels:  acl
Acl
The Hoa\Acl library.
Stars: ✭ 27 (-48.08%)
Mutual labels:  acl
zf3-circlical-user
Turnkey Authentication, Identity, and RBAC for Laminas and Zend Framework 3. Supports Doctrine and Middleware.
Stars: ✭ 35 (-32.69%)
Mutual labels:  acl
objection-authorize
isomorphic, "magical" authorization integration with Objection.js 🎉
Stars: ✭ 71 (+36.54%)
Mutual labels:  acl
emqx-dashboard-frontend
EMQ X Dashboard Frontend
Stars: ✭ 27 (-48.08%)
Mutual labels:  emqx
laminas-permissions-acl
Provides a lightweight and flexible access control list (ACL) implementation for privileges management
Stars: ✭ 29 (-44.23%)
Mutual labels:  acl
go-acl
Go library for manipulating ACLs on Windows
Stars: ✭ 97 (+86.54%)
Mutual labels:  acl
browser-acl
Simple acceess control (ACL) library for the browser inspired by Laravel's guards and policies.
Stars: ✭ 36 (-30.77%)
Mutual labels:  acl
dart-casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Dart/Flutter
Stars: ✭ 30 (-42.31%)
Mutual labels:  acl
sqlx-adapter
Asynchronous casbin adapter for mysql, postgres, sqlite based on sqlx-rs
Stars: ✭ 27 (-48.08%)
Mutual labels:  acl
laravel-vue-starter
Well Documented Laravel Starter App From Development to Production. For Full Blown RESTFUL API and SPA with Beautiful UI Using Buefy / ElementUi For Reusable Vue Components
Stars: ✭ 80 (+53.85%)
Mutual labels:  acl
shyft
⬡ Shyft is a server-side framework for building powerful GraphQL APIs 🚀
Stars: ✭ 56 (+7.69%)
Mutual labels:  acl
DPDK SURICATA-4 1 1
dpdk infrastructure for software acceleration. Currently working on RX and ACL pre-filter
Stars: ✭ 81 (+55.77%)
Mutual labels:  acl

emqx_auth_mysql

Authentication, ACL with MySQL Database.

Notice: changed mysql driver to mysql-otp.

Features

  • Full Authentication, Superuser, ACL support
  • IPv4, IPv6 and TLS support
  • Connection pool by ecpool
  • Completely cover MySQL 5.7, MySQL 8 in our tests

Build Plugin

make && make tests

Configure Plugin

File: etc/emqx_auth_mysql.conf

## MySQL server address.
##
## Value: Port | IP:Port
##
## Examples: 3306, 127.0.0.1:3306, localhost:3306
auth.mysql.server = 127.0.0.1:3306

## MySQL pool size.
##
## Value: Number
auth.mysql.pool = 8

## MySQL username.
##
## Value: String
## auth.mysql.username =

## MySQL Password.
##
## Value: String
## auth.mysql.password =

## MySQL database.
##
## Value: String
auth.mysql.database = mqtt

## Variables: %u = username, %c = clientid

## Authentication query.
##
## Note that column names should be 'password' and 'salt' (if used).
## In case column names differ in your DB - please use aliases,
## e.g. "my_column_name as password".
##
## Value: SQL
##
## Variables:
##  - %u: username
##  - %c: clientid
##  - %C: common name of client TLS cert
##  - %d: subject of client TLS cert
##
auth.mysql.auth_query = select password from mqtt_user where username = '%u' limit 1
## auth.mysql.auth_query = select password_hash as password from mqtt_user where username = '%u' limit 1

## Password hash.
##
## Value: plain | md5 | sha | sha256 | bcrypt
auth.mysql.password_hash = sha256

## sha256 with salt prefix
## auth.mysql.password_hash = salt,sha256

## bcrypt with salt only prefix
## auth.mysql.password_hash = salt,bcrypt

## sha256 with salt suffix
## auth.mysql.password_hash = sha256,salt

## pbkdf2 with macfun iterations dklen
## macfun: md4, md5, ripemd160, sha, sha224, sha256, sha384, sha512
## auth.mysql.password_hash = pbkdf2,sha256,1000,20

## Superuser query.
##
## Value: SQL
##
## Variables:
##  - %u: username
##  - %c: clientid
##  - %C: common name of client TLS cert
##  - %d: subject of client TLS cert
auth.mysql.super_query = select is_superuser from mqtt_user where username = '%u' limit 1

## ACL query.
##
## Value: SQL
##
## Variables:
##  - %a: ipaddr
##  - %u: username
##  - %c: clientid
## Note: You can add the 'ORDER BY' statement to control the rules match order
auth.mysql.acl_query = select allow, ipaddr, username, clientid, access, topic from mqtt_acl where ipaddr = '%a' or username = '%u' or username = '$all' or clientid = '%c'

Import mqtt.sql

Import mqtt.sql into your database.

Load Plugin

./bin/emqx_ctl plugins load emqx_auth_mysql

Auth Table

Notice: This is a demo table. You could authenticate with any user table.

CREATE TABLE `mqtt_user` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(100) DEFAULT NULL,
  `password` varchar(100) DEFAULT NULL,
  `salt` varchar(35) DEFAULT NULL,
  `is_superuser` tinyint(1) DEFAULT 0,
  `created` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mqtt_username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

ACL Table

CREATE TABLE `mqtt_acl` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `allow` int(1) DEFAULT NULL COMMENT '0: deny, 1: allow',
  `ipaddr` varchar(60) DEFAULT NULL COMMENT 'IpAddress',
  `username` varchar(100) DEFAULT NULL COMMENT 'Username',
  `clientid` varchar(100) DEFAULT NULL COMMENT 'ClientId',
  `access` int(2) NOT NULL COMMENT '1: subscribe, 2: publish, 3: pubsub',
  `topic` varchar(100) NOT NULL DEFAULT '' COMMENT 'Topic Filter',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

License

Apache License Version 2.0

Author

EMQ X Team.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].