chore(auth): configuration format of unified authentication plug-in

This commit is contained in:
zhanghongtong 2021-01-15 15:38:31 +08:00 committed by Rory Z
parent 7df1dea4db
commit 9e03d6fea1
10 changed files with 182 additions and 70 deletions

View File

@ -17,6 +17,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
fail-fast: false
matrix: matrix:
ldap_tag: ldap_tag:
- 2.4.50 - 2.4.50
@ -36,12 +37,12 @@ jobs:
if: matrix.network_type == 'ipv4' if: matrix.network_type == 'ipv4'
run: | run: |
server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ldap) server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ldap)
sed -i "/auth.ldap.servers/c auth.ldap.servers = $server_address" apps/emqx_auth_ldap/etc/emqx_auth_ldap.conf sed -i "s|^[#[:space:]]*auth.ldap.servers[[:space:]]*=.*|auth.ldap.servers = $server_address|g" apps/emqx_auth_ldap/etc/emqx_auth_ldap.conf
- name: setup - name: setup
if: matrix.network_type == 'ipv6' if: matrix.network_type == 'ipv6'
run: | run: |
server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' ldap) server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' ldap)
sed -i "/auth.ldap.servers/c auth.ldap.servers = $server_address" apps/emqx_auth_ldap/etc/emqx_auth_ldap.conf sed -i "s|^[#[:space:]]*auth.ldap.servers[[:space:]]*=.*|auth.ldap.servers = $server_address|g" apps/emqx_auth_ldap/etc/emqx_auth_ldap.conf
- name: run test cases - name: run test cases
run: | run: |
docker exec -i erlang sh -c "make ensure-rebar3" docker exec -i erlang sh -c "make ensure-rebar3"
@ -57,6 +58,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
fail-fast: false
matrix: matrix:
mongo_tag: mongo_tag:
- 3 - 3
@ -76,10 +78,10 @@ jobs:
if: matrix.connect_type == 'tls' if: matrix.connect_type == 'tls'
run: | run: |
docker-compose -f .ci/compatibility_tests/docker-compose-mongo-tls.yaml up -d docker-compose -f .ci/compatibility_tests/docker-compose-mongo-tls.yaml up -d
echo 'auth.mongo.ssl = on' >> apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf sed -i 's|^[#[:space:]]*auth.mongo.ssl[[:space:]]*=.*|auth.mongo.ssl = on|g' apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf
echo 'auth.mongo.ssl.cacertfile = /emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/ca.pem' >> apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf sed -i 's|^[#[:space:]]*auth.mongo.cacertfile[[:space:]]*=.*|auth.mongo.cacertfile = /emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/ca.pem|g' apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf
echo 'auth.mongo.ssl.certfile = /emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/client-cert.pem' >> apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf sed -i 's|^[#[:space:]]*auth.mongo.certfile[[:space:]]*=.*|auth.mongo.certfile = /emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/client-cert.pem|g' apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf
echo 'auth.mongo.ssl.keyfile = /emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/client-key.pem' >> apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf sed -i 's|^[#[:space:]]*auth.mongo.keyfile[[:space:]]*=.*|auth.mongo.keyfile = /emqx/apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/client-key.pem|g' apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf
- name: setup - name: setup
env: env:
MONGO_TAG: ${{ matrix.mongo_tag }} MONGO_TAG: ${{ matrix.mongo_tag }}
@ -89,12 +91,12 @@ jobs:
if: matrix.network_type == 'ipv4' if: matrix.network_type == 'ipv4'
run: | run: |
server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mongo) server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mongo)
sed -i "/auth.mongo.server/c auth.mongo.server = $server_address:27017" apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf sed -i "s|^[#[:space:]]*auth.mongo.server[[:space:]]*=.*|auth.mongo.server = $server_address:27017|g" apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf
- name: setup - name: setup
if: matrix.network_type == 'ipv6' if: matrix.network_type == 'ipv6'
run: | run: |
server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' mongo) server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' mongo)
sed -i "/auth.mongo.server/c auth.mongo.server = $server_address:27017" apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf sed -i "s|^[#[:space:]]*auth.mongo.server[[:space:]]*=.*|auth.mongo.server = $server_address:27017|g" apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf
- name: run test cases - name: run test cases
run: | run: |
docker exec -i erlang sh -c "make ensure-rebar3" docker exec -i erlang sh -c "make ensure-rebar3"
@ -110,6 +112,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
fail-fast: false
matrix: matrix:
mysql_tag: mysql_tag:
- 5.7 - 5.7
@ -129,11 +132,10 @@ jobs:
if: matrix.connect_type == 'tls' if: matrix.connect_type == 'tls'
run: | run: |
docker-compose -f .ci/compatibility_tests/docker-compose-mysql-tls.yaml up -d docker-compose -f .ci/compatibility_tests/docker-compose-mysql-tls.yaml up -d
echo '\n' >> apps/emqx_auth_mongo/etc/emqx_auth_mysql.conf sed -i 's|^[#[:space:]]*auth.mysql.ssl[[:space:]]*=.*|auth.mysql.ssl = on|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
sed -i '/auth.mysql.ssl = off/c auth.mysql.ssl = on' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf sed -i 's|^[#[:space:]]*auth.mysql.cacertfile[[:space:]]*=.*|auth.mysql.cacertfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/ca.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
echo "auth.mysql.ssl.cafile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/ca.pem" >> apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf sed -i 's|^[#[:space:]]*auth.mysql.certfile[[:space:]]*=.*|auth.mysql.certfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-cert.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
echo "auth.mysql.ssl.certfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-cert.pem" >> apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf sed -i 's|^[#[:space:]]*auth.mysql.keyfile[[:space:]]*=.*|auth.mysql.keyfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-key.pem|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
echo "auth.mysql.ssl.keyfile = /emqx/apps/emqx_auth_mysql/test/emqx_auth_mysql_SUITE_data/client-key.pem" >> apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
- name: setup - name: setup
env: env:
MYSQL_TAG: ${{ matrix.mysql_tag }} MYSQL_TAG: ${{ matrix.mysql_tag }}
@ -149,6 +151,11 @@ jobs:
run: | run: |
server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' mysql) server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' mysql)
sed -i "/auth.mysql.server/c auth.mysql.server = $server_address:3306" apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf sed -i "/auth.mysql.server/c auth.mysql.server = $server_address:3306" apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
- name: setup
run: |
sed -i 's|^[#[:space:]]*auth.mysql.username[[:space:]]*=.*|auth.mysql.username = root|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
sed -i 's|^[#[:space:]]*auth.mysql.password[[:space:]]*=.*|auth.mysql.password = public|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
sed -i 's|^[#[:space:]]*auth.mysql.database[[:space:]]*=.*|auth.mysql.database = mqtt|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
- name: run test cases - name: run test cases
run: | run: |
docker exec -i erlang sh -c "make ensure-rebar3" docker exec -i erlang sh -c "make ensure-rebar3"
@ -164,6 +171,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
fail-fast: false
matrix: matrix:
pgsql_tag: pgsql_tag:
- 9 - 9
@ -186,27 +194,30 @@ jobs:
run: | run: |
docker-compose -f .ci/compatibility_tests/docker-compose-pgsql-tls.yaml build --no-cache docker-compose -f .ci/compatibility_tests/docker-compose-pgsql-tls.yaml build --no-cache
docker-compose -f .ci/compatibility_tests/docker-compose-pgsql-tls.yaml up -d docker-compose -f .ci/compatibility_tests/docker-compose-pgsql-tls.yaml up -d
sed -i 's|auth.pgsql.username[ \t]*=.*|auth.pgsql.username = postgres|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf sed -i 's|^[#[:space:]]*auth.pgsql.username[ \t]*=.*|auth.pgsql.username = postgres|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i 's|auth.pgsql.password[ \t]*=.*|auth.pgsql.password = postgres|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf sed -i 's|^[#[:space:]]*auth.pgsql.password[ \t]*=.*|auth.pgsql.password = postgres|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i 's|auth.pgsql.database[ \t]*=.*|auth.pgsql.database= postgres|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf sed -i 's|^[#[:space:]]*auth.pgsql.database[ \t]*=.*|auth.pgsql.database = postgres|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i 's|auth.pgsql.ssl[ \t]*=.*|auth.pgsql.ssl = on|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf sed -i 's|^[#[:space:]]*auth.pgsql.ssl[ \t]*=.*|auth.pgsql.ssl = on|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
echo '\n' >> apps/emqx_auth_mongo/etc/emqx_auth_pgsql.conf sed -i 's|^[#[:space:]]*auth.pgsql.cacertfile[ \t]*=.*|auth.pgsql.cacertfile = /emqx/apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/root.crt|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
echo 'auth.pgsql.ssl.cacertfile = /emqx/apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE_data/root.crt' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
- name: setup - name: setup
env: env:
PGSQL_TAG: ${{ matrix.pgsql_tag }} PGSQL_TAG: ${{ matrix.pgsql_tag }}
if: matrix.connect_type == 'tcp' if: matrix.connect_type == 'tcp'
run: docker-compose -f .ci/compatibility_tests/docker-compose-pgsql.yaml up -d run: |
docker-compose -f .ci/compatibility_tests/docker-compose-pgsql.yaml up -d
sed -i 's|^[#[:space:]]*auth.pgsql.username[ \t]*=.*|auth.pgsql.username = root|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i 's|^[#[:space:]]*auth.pgsql.password[ \t]*=.*|auth.pgsql.password = public|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i 's|^[#[:space:]]*auth.pgsql.database[ \t]*=.*|auth.pgsql.database = mqtt|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
- name: setup - name: setup
if: matrix.network_type == 'ipv4' if: matrix.network_type == 'ipv4'
run: | run: |
server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgsql) server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgsql)
sed -i "/auth.pgsql.server/c auth.pgsql.server = $server_address:5432" apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf sed -i "s|^[#[:space:]]*auth.pgsql.server[[:space:]]*=.*|auth.pgsql.server = $server_address:5432|g" apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
- name: setup - name: setup
if: matrix.network_type == 'ipv6' if: matrix.network_type == 'ipv6'
run: | run: |
server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' pgsql) server_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.GlobalIPv6Address}}{{end}}' pgsql)
sed -i "/auth.pgsql.server/c auth.pgsql.server = $server_address:5432" apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf sed -i "s|^[#[:space:]]*auth.pgsql.server[[:space:]]*=.*|auth.pgsql.server = $server_address:5432|g" apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
- name: run test cases - name: run test cases
run: | run: |
docker exec -i erlang sh -c "make ensure-rebar3" docker exec -i erlang sh -c "make ensure-rebar3"
@ -222,6 +233,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
fail-fast: false
matrix: matrix:
redis_tag: redis_tag:
- 5 - 5
@ -245,11 +257,10 @@ jobs:
run: | run: |
set -exu set -exu
docker-compose -f .ci/compatibility_tests/docker-compose-redis-${{ matrix.node_type }}-tls.yaml up -d docker-compose -f .ci/compatibility_tests/docker-compose-redis-${{ matrix.node_type }}-tls.yaml up -d
echo '\n' >> apps/emqx_auth_mongo/etc/emqx_auth_redis.conf sed -i 's|^[#[:space:]]*auth.redis.ssl[[:space:]]*=.*|auth.redis.ssl = on|g' apps/emqx_auth_redis/etc/emqx_auth_redis.conf
echo 'auth.redis.ssl = on' >> apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i 's|^[#[:space:]]*auth.redis.ssl.cacertfile[[:space:]]*=.*|auth.redis.ssl.cacertfile = /emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/ca.crt|g' apps/emqx_auth_redis/etc/emqx_auth_redis.conf
echo 'auth.redis.ssl.cafile = /emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/ca.crt' >> apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i 's|^[#[:space:]]*auth.redis.ssl.certfile[[:space:]]*=.*|auth.redis.ssl.certfile = /emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/redis.crt|g' apps/emqx_auth_redis/etc/emqx_auth_redis.conf
echo 'auth.redis.ssl.certfile = /emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/redis.crt' >> apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i 's|^[#[:space:]]*auth.redis.ssl.keyfile[[:space:]]*=.*|auth.redis.ssl.keyfile = /emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/redis.key|g' apps/emqx_auth_redis/etc/emqx_auth_redis.conf
echo 'auth.redis.ssl.keyfile = /emqx/apps/emqx_auth_redis/test/emqx_auth_redis_SUITE_data/certs/redis.key' >> apps/emqx_auth_redis/etc/emqx_auth_redis.conf
- name: setup - name: setup
env: env:
REDIS_TAG: ${{ matrix.redis_tag }} REDIS_TAG: ${{ matrix.redis_tag }}
@ -267,24 +278,24 @@ jobs:
if: matrix.node_type == 'singer' && matrix.connect_type == 'tcp' if: matrix.node_type == 'singer' && matrix.connect_type == 'tcp'
run: | run: |
set -exu set -exu
sed -i "/auth.redis.server/c auth.redis.server = ${redis_${{ matrix.network_type }}_address}:6379" apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i "s|^[#[:space:]]*auth.redis.server[[:space:]]*=.*|auth.redis.server = ${redis_${{ matrix.network_type }}_address}:6379|g" apps/emqx_auth_redis/etc/emqx_auth_redis.conf
- name: setup - name: setup
if: matrix.node_type == 'singer' && matrix.connect_type == 'tls' && matrix.redis_tag != '5' if: matrix.node_type == 'singer' && matrix.connect_type == 'tls' && matrix.redis_tag != '5'
run: | run: |
set -exu set -exu
sed -i "/auth.redis.server/c auth.redis.server = ${redis_${{ matrix.network_type }}_address}:6380" apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i "s|^[#[:space:]]*auth.redis.server[[:space:]]*=.*|auth.redis.server = ${redis_${{ matrix.network_type }}_address}:6380|g" apps/emqx_auth_redis/etc/emqx_auth_redis.conf
- name: setup - name: setup
if: matrix.node_type == 'cluster' && matrix.connect_type == 'tcp' if: matrix.node_type == 'cluster' && matrix.connect_type == 'tcp'
run: | run: |
set -exu set -exu
sed -i "/auth.redis.type/c auth.redis.type = cluster" apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i 's|^[#[:space:]]*auth.redis.type[[:space:]]*=.*|auth.redis.type = cluster|g' apps/emqx_auth_redis/etc/emqx_auth_redis.conf
sed -i "/auth.redis.server/c auth.redis.server = ${redis_${{ matrix.network_type }}_address}:7000, ${redis_${{ matrix.network_type }}_address}:7001, ${redis_${{ matrix.network_type }}_address}:7002" apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i "s|^[#[:space:]]*auth.redis.server[[:space:]]*=.*|auth.redis.server = ${redis_${{ matrix.network_type }}_address}:7000, ${redis_${{ matrix.network_type }}_address}:7001, ${redis_${{ matrix.network_type }}_address}:7002|g" apps/emqx_auth_redis/etc/emqx_auth_redis.conf
- name: setup - name: setup
if: matrix.node_type == 'cluster' && matrix.connect_type == 'tls' && matrix.redis_tag != '5' if: matrix.node_type == 'cluster' && matrix.connect_type == 'tls' && matrix.redis_tag != '5'
run: | run: |
set -exu set -exu
sed -i "/auth.redis.type/c auth.redis.type = cluster" apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i 's|^[#[:space:]]*auth.redis.type[[:space:]]*=.*|auth.redis.type = cluster|g' apps/emqx_auth_redis/etc/emqx_auth_redis.conf
sed -i "/auth.redis.server/c auth.redis.server = ${redis_${{ matrix.network_type }}_address}:8000, ${redis_${{ matrix.network_type }}_address}:8001, ${redis_${{ matrix.network_type }}_address}:8002" apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i "s|^[#[:space:]]*auth.redis.server[[:space:]]*=.*|auth.redis.server = ${redis_${{ matrix.network_type }}_address}:8000, ${redis_${{ matrix.network_type }}_address}:8001, ${redis_${{ matrix.network_type }}_address}:8002|g" apps/emqx_auth_redis/etc/emqx_auth_redis.conf
- name: run test cases - name: run test cases
if: matrix.connect_type == 'tcp' || (matrix.connect_type == 'tls' && matrix.redis_tag != '5') if: matrix.connect_type == 'tcp' || (matrix.connect_type == 'tls' && matrix.redis_tag != '5')
run: | run: |

View File

@ -30,11 +30,19 @@ jobs:
docker-compose -f .ci/apps_tests/docker-compose.yaml up -d docker-compose -f .ci/apps_tests/docker-compose.yaml up -d
- name: set config files - name: set config files
run: | run: |
sed -i "/auth.mysql.server/c auth.mysql.server = mysql_server:3306" apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf sed -i 's|^[#[:space:]]*auth.ldap.servers[[:space:]]*=.*|auth.ldap.servers = ldap_server|g' apps/emqx_auth_ldap/etc/emqx_auth_ldap.conf
sed -i "/auth.redis.server/c auth.redis.server = redis_server:6379" apps/emqx_auth_redis/etc/emqx_auth_redis.conf sed -i 's|^[#[:space:]]*auth.mongo.server[[:space:]]*=.*|auth.mongo.server = mongo_server:27017|g' apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf
sed -i "/auth.mongo.server/c auth.mongo.server = mongo_server:27017" apps/emqx_auth_mongo/etc/emqx_auth_mongo.conf sed -i 's|^[#[:space:]]*auth.redis.server[[:space:]]*=.*|auth.redis.server = redis_server:6379|g' apps/emqx_auth_redis/etc/emqx_auth_redis.conf
sed -i "/auth.pgsql.server/c auth.pgsql.server = pgsql_server:5432" apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i "/auth.ldap.servers/c auth.ldap.servers = ldap_server" apps/emqx_auth_ldap/etc/emqx_auth_ldap.conf sed -i 's|^[#[:space:]]*auth.mysql.server[[:space:]]*=.*|auth.mysql.server = mysql_server:3306|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
sed -i 's|^[#[:space:]]*auth.mysql.username[[:space:]]*=.*|auth.mysql.username = root|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
sed -i 's|^[#[:space:]]*auth.mysql.password[[:space:]]*=.*|auth.mysql.password = public|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
sed -i 's|^[#[:space:]]*auth.mysql.database[[:space:]]*=.*|auth.mysql.database = mqtt|g' apps/emqx_auth_mysql/etc/emqx_auth_mysql.conf
sed -i 's|^[#[:space:]]*auth.pgsql.server[[:space:]]*=.*|auth.pgsql.server = pgsql_server:5432|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i 's|^[#[:space:]]*auth.pgsql.username[[:space:]]*=.*|auth.pgsql.username = root|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i 's|^[#[:space:]]*auth.pgsql.password[[:space:]]*=.*|auth.pgsql.password = public|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
sed -i 's|^[#[:space:]]*auth.pgsql.database[[:space:]]*=.*|auth.pgsql.database = mqtt|g' apps/emqx_auth_pgsql/etc/emqx_auth_pgsql.conf
- name: run tests - name: run tests
run: | run: |
docker exec -i erlang bash -c "make xref" docker exec -i erlang bash -c "make xref"

View File

@ -27,7 +27,7 @@ auth.mongo.pool = 8
## MongoDB login user. ## MongoDB login user.
## ##
## Value: String ## Value: String
## auth.mongo.login = # auth.mongo.username =
## MongoDB password. ## MongoDB password.
## ##

View File

@ -21,11 +21,17 @@
{datatype, integer} {datatype, integer}
]}. ]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.mongo.login", "emqx_auth_mongo.server", [ {mapping, "auth.mongo.login", "emqx_auth_mongo.server", [
{default, ""}, {default, ""},
{datatype, string} {datatype, string}
]}. ]}.
{mapping, "auth.mongo.username", "emqx_auth_mongo.server", [
{default, ""},
{datatype, string}
]}.
{mapping, "auth.mongo.password", "emqx_auth_mongo.server", [ {mapping, "auth.mongo.password", "emqx_auth_mongo.server", [
{default, ""}, {default, ""},
{datatype, string} {datatype, string}
@ -43,7 +49,7 @@
{mapping, "auth.mongo.ssl", "emqx_auth_mongo.server", [ {mapping, "auth.mongo.ssl", "emqx_auth_mongo.server", [
{default, off}, {default, off},
{datatype, flag} {datatype, {enum, [on, off, true, false]}} %% FIXME: ture/false is compatible with 4.0-4.2 version format, plan to delete in 5.0
]}. ]}.
{mapping, "auth.mongo.ssl.keyfile", "emqx_auth_mongo.server", [ {mapping, "auth.mongo.ssl.keyfile", "emqx_auth_mongo.server", [
@ -58,6 +64,21 @@
{datatype, string} {datatype, string}
]}. ]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.mongo.ssl_opts.keyfile", "emqx_auth_mongo.server", [
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.mongo.ssl_opts.certfile", "emqx_auth_mongo.server", [
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.mongo.ssl_opts.cacertfile", "emqx_auth_mongo.server", [
{datatype, string}
]}.
{mapping, "auth.mongo.w_mode", "emqx_auth_mongo.server", [ {mapping, "auth.mongo.w_mode", "emqx_auth_mongo.server", [
{default, undef}, {default, undef},
{datatype, {enum, [safe, unsafe, undef]}} {datatype, {enum, [safe, unsafe, undef]}}
@ -77,7 +98,10 @@
Hosts = string:tokens(H, ","), Hosts = string:tokens(H, ","),
Type0 = cuttlefish:conf_get("auth.mongo.type", Conf), Type0 = cuttlefish:conf_get("auth.mongo.type", Conf),
Pool = cuttlefish:conf_get("auth.mongo.pool", Conf), Pool = cuttlefish:conf_get("auth.mongo.pool", Conf),
Login = cuttlefish:conf_get("auth.mongo.login", Conf), %% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
Login = cuttlefish:conf_get("auth.mongo.username", Conf,
cuttlefish:conf_get("auth.mongo.login", Conf)
),
Passwd = cuttlefish:conf_get("auth.mongo.password", Conf), Passwd = cuttlefish:conf_get("auth.mongo.password", Conf),
DB = cuttlefish:conf_get("auth.mongo.database", Conf), DB = cuttlefish:conf_get("auth.mongo.database", Conf),
AuthSrc = cuttlefish:conf_get("auth.mongo.auth_source", Conf), AuthSrc = cuttlefish:conf_get("auth.mongo.auth_source", Conf),
@ -99,18 +123,28 @@
true -> []; true -> [];
false -> [{r_mode, R}] false -> [{r_mode, R}]
end, end,
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
SslOpts = fun(Prefix) ->
Filter([{keyfile, cuttlefish:conf_get(Prefix ++ ".keyfile", Conf, undefined)},
{certfile, cuttlefish:conf_get(Prefix ++ ".certfile", Conf, undefined)},
{cacertfile, cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf, undefined)}])
end,
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
GenSsl = case cuttlefish:conf_get("auth.mongo.ssl.cacertfile", Conf, undefined) of
undefined -> [{ssl, true}, {ssl_opts, SslOpts("auth.mongo.ssl_opts")}];
_ -> [{ssl, true}, {ssl_opts, SslOpts("auth.mongo.ssl")}]
end,
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
Ssl = case cuttlefish:conf_get("auth.mongo.ssl", Conf) of Ssl = case cuttlefish:conf_get("auth.mongo.ssl", Conf) of
true -> on -> GenSsl;
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end, off -> [];
SslOpts = fun(Prefix) -> true -> GenSsl;
Filter([{keyfile, cuttlefish:conf_get(Prefix ++ ".keyfile", Conf, undefined)}, false -> []
{certfile, cuttlefish:conf_get(Prefix ++ ".certfile", Conf, undefined)}, end,
{cacertfile, cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf, undefined)}])
end,
[{ssl, true}, {ssl_opts, SslOpts("auth.mongo.ssl")}];
false ->
[]
end,
WorkerOptions = [{database, list_to_binary(DB)}, {auth_source, list_to_binary(AuthSrc)}] WorkerOptions = [{database, list_to_binary(DB)}, {auth_source, list_to_binary(AuthSrc)}]
++ Login0 ++ Passwd0 ++ W0 ++ R0 ++ Ssl, ++ Login0 ++ Passwd0 ++ W0 ++ R0 ++ Ssl,

View File

@ -17,12 +17,12 @@ auth.mysql.pool = 8
## MySQL username. ## MySQL username.
## ##
## Value: String ## Value: String
auth.mysql.username = root # auth.mysql.username =
## MySQL password. ## MySQL password.
## ##
## Value: String ## Value: String
auth.mysql.password = public # auth.mysql.password =
## MySQL database. ## MySQL database.
## ##
@ -103,7 +103,7 @@ auth.mysql.acl_query = select allow, ipaddr, username, clientid, access, topic f
## CA certificate. ## CA certificate.
## ##
## Value: File ## Value: File
## auth.mysql.ssl.cafile = path to your ca file # auth.mysql.ssl.cacertfile = /path/to/ca.pem
## Client ssl certificate. ## Client ssl certificate.
## ##

View File

@ -40,6 +40,12 @@
{datatype, string} {datatype, string}
]}. ]}.
{mapping, "auth.mysql.ssl.cacertfile", "emqx_auth_mysql.server", [
{default, ""},
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.mysql.ssl.certfile", "emqx_auth_mysql.server", [ {mapping, "auth.mysql.ssl.certfile", "emqx_auth_mysql.server", [
{default, ""}, {default, ""},
{datatype, string} {datatype, string}
@ -84,7 +90,10 @@
Options1 = Options1 =
case cuttlefish:conf_get("auth.mysql.ssl", Conf) of case cuttlefish:conf_get("auth.mysql.ssl", Conf) of
true -> true ->
CA = cuttlefish:conf_get("auth.mysql.ssl.cafile", Conf), %% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
CA = cuttlefish:conf_get("auth.mysql.ssl.cacertfile", Conf,
cuttlefish:conf_get("auth.mysql.ssl.cafile", Conf)
),
Cert = cuttlefish:conf_get("auth.mysql.ssl.certfile", Conf), Cert = cuttlefish:conf_get("auth.mysql.ssl.certfile", Conf),
Key = cuttlefish:conf_get("auth.mysql.ssl.keyfile", Conf), Key = cuttlefish:conf_get("auth.mysql.ssl.keyfile", Conf),
Options ++ [{ssl, {server_name_indication, disable}, Options ++ [{ssl, {server_name_indication, disable},

View File

@ -22,7 +22,7 @@ auth.pgsql.username = root
## PostgreSQL password. ## PostgreSQL password.
## ##
## Value: String ## Value: String
auth.pgsql.password = public # auth.pgsql.password =
## PostgreSQL database. ## PostgreSQL database.
## ##

View File

@ -32,7 +32,7 @@
{mapping, "auth.pgsql.ssl", "emqx_auth_pgsql.server", [ {mapping, "auth.pgsql.ssl", "emqx_auth_pgsql.server", [
{default, off}, {default, off},
{datatype, flag} {datatype, {enum, [on, off, true, false]}} %% FIXME: true/fasle is compatible with 4.0-4.2 version format, plan to delete in 5.0
]}. ]}.
{mapping, "auth.pgsql.ssl.keyfile", "emqx_auth_pgsql.server", [ {mapping, "auth.pgsql.ssl.keyfile", "emqx_auth_pgsql.server", [
@ -47,6 +47,21 @@
{datatype, string} {datatype, string}
]}. ]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.pgsql.ssl_opts.keyfile", "emqx_auth_pgsql.server", [
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.pgsql.ssl_opts.certfile", "emqx_auth_pgsql.server", [
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.pgsql.ssl_opts.cacertfile", "emqx_auth_pgsql.server", [
{datatype, string}
]}.
{translation, "emqx_auth_pgsql.server", fun(Conf) -> {translation, "emqx_auth_pgsql.server", fun(Conf) ->
{PgHost, PgPort} = {PgHost, PgPort} =
case cuttlefish:conf_get("auth.pgsql.server", Conf) of case cuttlefish:conf_get("auth.pgsql.server", Conf) of
@ -61,7 +76,6 @@
Passwd = cuttlefish:conf_get("auth.pgsql.password", Conf, ""), Passwd = cuttlefish:conf_get("auth.pgsql.password", Conf, ""),
DB = cuttlefish:conf_get("auth.pgsql.database", Conf), DB = cuttlefish:conf_get("auth.pgsql.database", Conf),
Encoding = cuttlefish:conf_get("auth.pgsql.encoding", Conf), Encoding = cuttlefish:conf_get("auth.pgsql.encoding", Conf),
Ssl = cuttlefish:conf_get("auth.pgsql.ssl", Conf),
Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end, Filter = fun(Opts) -> [{K, V} || {K, V} <- Opts, V =/= undefined] end,
SslOpts = fun(Prefix) -> SslOpts = fun(Prefix) ->
@ -69,6 +83,20 @@
{certfile, cuttlefish:conf_get(Prefix ++ ".certfile", Conf, undefined)}, {certfile, cuttlefish:conf_get(Prefix ++ ".certfile", Conf, undefined)},
{cacertfile, cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf, undefined)}]) {cacertfile, cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf, undefined)}])
end, end,
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
GenSsl = case cuttlefish:conf_get("auth.pgsql.ssl.cacertfile", Conf, undefined) of
undefined -> [{ssl, true}, {ssl_opts, SslOpts("auth.pgsql.ssl_opts")}];
_ -> [{ssl, true}, {ssl_opts, SslOpts("auth.pgsql.ssl")}]
end,
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
Ssl = case cuttlefish:conf_get("auth.pgsql.ssl", Conf) of
on -> GenSsl;
off -> [];
true -> GenSsl;
false -> []
end,
TempHost = case inet:parse_address(PgHost) of TempHost = case inet:parse_address(PgHost) of
{ok, IpAddr} -> {ok, IpAddr} ->
@ -83,9 +111,7 @@
{username, Username}, {username, Username},
{password, Passwd}, {password, Passwd},
{database, DB}, {database, DB},
{encoding, Encoding}, {encoding, Encoding}] ++ Ssl
{ssl, Ssl},
{ssl_opts, SslOpts("auth.pgsql.ssl")}]
end}. end}.
{mapping, "auth.pgsql.auth_query", "emqx_auth_pgsql.auth_query", [ {mapping, "auth.pgsql.auth_query", "emqx_auth_pgsql.auth_query", [

View File

@ -103,7 +103,7 @@ auth.redis.acl_cmd = HGETALL mqtt_acl:%u
## CA certificate. ## CA certificate.
## ##
## Value: File ## Value: File
#auth.redis.ssl.cafile = path/to/your/cafile # auth.redis.ssl.cacertfile = path/to/your/cafile.pem
## Client ssl certificate. ## Client ssl certificate.
## ##

View File

@ -38,11 +38,12 @@
{datatype, flag} {datatype, flag}
]}. ]}.
{mapping, "auth.redis.ssl.cafile", "emqx_auth_redis.options", [ {mapping, "auth.redis.ssl.cacertfile", "emqx_auth_redis.options", [
{default, ""}, {default, ""},
{datatype, string} {datatype, string}
]}. ]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.redis.ssl.certfile", "emqx_auth_redis.options", [ {mapping, "auth.redis.ssl.certfile", "emqx_auth_redis.options", [
{default, ""}, {default, ""},
{datatype, string} {datatype, string}
@ -53,16 +54,39 @@
{datatype, string} {datatype, string}
]}. ]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.redis.cafile", "emqx_auth_redis.options", [
{default, ""},
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.redis.certfile", "emqx_auth_redis.options", [
{default, ""},
{datatype, string}
]}.
%% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
{mapping, "auth.redis.keyfile", "emqx_auth_redis.options", [
{default, ""},
{datatype, string}
]}.
{translation, "emqx_auth_redis.options", fun(Conf) -> {translation, "emqx_auth_redis.options", fun(Conf) ->
Ssl = cuttlefish:conf_get("auth.redis.ssl", Conf, false), Ssl = cuttlefish:conf_get("auth.redis.ssl", Conf, false),
case Ssl of case Ssl of
true -> true ->
CA = cuttlefish:conf_get("auth.redis.ssl.cafile", Conf), %% FIXME: compatible with 4.0-4.2 version format, plan to delete in 5.0
Cert = cuttlefish:conf_get("auth.redis.ssl.certfile", Conf), Prefix = case cuttlefish:conf_get("auth.redis.ssl.cacertfile", Conf, undefined) of
Key = cuttlefish:conf_get("auth.redis.ssl.keyfile", Conf), undefined -> "auth.redis";
[{options, [{ssl_options, [{cacertfile, CA}, _ -> "auth.redis.ssl"
{certfile, Cert}, end,
{keyfile, Key}]}]}]; CA = cuttlefish:conf_get(Prefix ++ ".cacertfile", Conf),
Cert = cuttlefish:conf_get(Prefix ++ ".certfile", Conf),
Key = cuttlefish:conf_get(Prefix ++ ".keyfile", Conf),
[{options, [{ssl_options, [{cacertfile, CA},
{certfile, Cert},
{keyfile, Key}]}]}];
_ -> [{options, []}] _ -> [{options, []}]
end end
end}. end}.