Commit Graph

2482 Commits

Author SHA1 Message Date
JianBo He 883c1b2e59 chore(gw): remove needless lines 2021-11-16 10:00:54 +08:00
JianBo He cf1d98adc6 chore(gw): save cert files 2021-11-16 10:00:54 +08:00
JianBo He 5a08fa6a03 docs(gw): add gateway comment 2021-11-16 10:00:54 +08:00
JianBo He 1f067d6f3b docs(gw): add docs for gateway schema 2021-11-16 10:00:54 +08:00
JianBo He bc3f3b4c55 test(gw): more robust testing 2021-11-16 10:00:53 +08:00
JianBo He 287859fe36 chore(gw): integrate emqx-conf 2021-11-16 09:58:37 +08:00
JianBo He 0b36b73ee1 fix(emqx_conf): fix badmatch for returned error value 2021-11-16 09:58:37 +08:00
JianBo He cf17a55079 chore(gw): rename cm-registry shard name 2021-11-16 09:58:37 +08:00
JimMoen c05ecdbcb8
fix(api): DELETE success wrongly returned code 200 (#6135) 2021-11-16 09:28:57 +08:00
Zaiming Shi ff23e9dde1 test: sync with emqx_cm process before flushing emqx_pool 2021-11-15 22:27:16 +01:00
JianBo He a113b9b65d chore: fix elvis warnings 2021-11-15 22:26:46 +01:00
JianBo He 9e333ac8b3 fix(emqx_cm): fix typos 2021-11-15 22:26:46 +01:00
Zaiming Shi dd771c5568 fix(emqx_mgmt_cli): idempontent kick. now it always returns ok 2021-11-15 22:26:46 +01:00
Zaiming Shi 7e2ca9e287 fix(session): force kill session for 'kick' and 'discard'
Prior to this fix, 'kick' and 'discard' calls may timeout (or
fail for other reason), failures lead to only a log, then
continue to allow the new session to get registered.

As a result, in case a client is stuck, there is no way to
force it to step down, end up with multiple connections (sessions)
for the client ID in dashboard.

After this fix, the stale pids are notified to shutdown
via a gen_server:call, and forced with a exit(Pid, kill) for any
exception happend to the gen_server:call
2021-11-15 22:26:46 +01:00
Zaiming (Stone) Shi 650905667b
Merge pull request #6172 from JimMoen/fix-emqx_cm-ct
test: add tasks flushing in emqx_cm cases
2021-11-15 17:17:27 +01:00
JimMoen cf80aaacc3 test: add tasks flushing in emqx_cm cases 2021-11-15 20:40:43 +08:00
Zaiming (Stone) Shi 9761fe2f6d
Merge pull request #6009 from tigercl/fix/authn
fix(authn): fix handling of query result
2021-11-15 13:32:56 +01:00
JimMoen dcc5ae0642 test: API return code section 2021-11-15 16:30:44 +08:00
JimMoen b3f9220d02 style: make elvis happy 2021-11-15 16:30:44 +08:00
JimMoen 106aa559e0 fix(api): DELETE success wrongly returned code 200 2021-11-15 16:30:44 +08:00
JimMoen 59e6b6ee5b
test(cm): add sleep time for multicore scheduling (#6164) 2021-11-15 15:43:26 +08:00
DDDHuang 1476accd63
fix: monitor bad mnesia write & rpc call (#6060) 2021-11-15 15:28:19 +08:00
zhongwencool 01f29ab052
chore(swagger): lwm2m2 http api to hocon (#6153) 2021-11-15 15:08:50 +08:00
JimMoen 5a928ad8c3 test(cm): add sleep time for multicore scheduling 2021-11-15 13:52:15 +08:00
DDDHuang f0107868d4
fix: test suite stable (#6136)
* fix: test suite stable
2021-11-12 10:53:30 +08:00
JimMoen 9b17757ae8 style: make elvis happy 2021-11-12 09:29:26 +08:00
JimMoen 37cdd429b2 fix(api): remove sessionID from client information 2021-11-12 09:29:26 +08:00
DDDHuang bc6e49804f
feat: support CORS request
feat: support CORS request
2021-11-11 20:27:39 +08:00
zhongwencool 7a5da76197
Mgmt http api banned (#5998)
* fix(swagger): don't transform [log,publish] to a list.pwd

* chore: replace banned-api by hocon schema

* fix(api): code style warning
2021-11-11 16:35:29 +08:00
JimMoen a65597e302
Authz api mnesia refactor (#6082)
* refactor(authz): macro move to hrl and rename, add meta example

* refactor(authz_api_mnesia): use config schemas for request validations

* chore(authz_api_mnesia): suite module typerefl fit

* chore(style): authz_api_mnesia style format
2021-11-11 16:29:36 +08:00
Zaiming Shi b96a106463 style: make elvis happy 2021-11-10 22:54:58 +01:00
Zaiming Shi 9c1972020c test: fix flaky test emqx_stomp_SUITE:t_rest_clienit_inf 2021-11-10 22:51:18 +01:00
Ilya Averyanov 4f0311b6f8
Merge pull request #6093 from savonarola/add-authn-tests
chore(authn mnesia): reimplement emqx_authn_mnesia provider tests
2021-11-10 21:20:46 +03:00
Ilya Averyanov a0a88e23b0 chore(authn mnesia): reimplement emqx_authn_mnesia provider tests 2021-11-10 17:13:04 +03:00
Thales Macedo Garitezi 60d5017eea
style(elvis): fix elvis style complaints 2021-11-10 11:12:10 -03:00
Thales Macedo Garitezi 8fe342a02d
feat(stats): track live channel / client count
Track connected client count

In order to correctly display the number of _connected_ clients in our
monitor dashboard, we need to track those connections that are
actually connected to clients, not considering connections from
persistent sessions that are disconnected. Today, the
`connections.count` that is displayed in the dashboards considers
those disconnected persistent sessions as well.

The new statistics can be found in the
[`emqx_management`](https://github.com/emqx/emqx/tree/main-v4.4/apps/emqx_management)
plugin, under `/api/v4/stats`, in the keys
`live_connections.{max,count}`.
2021-11-10 11:12:10 -03:00
lafirest e8f6035c34
feat(emqx_lwm2m): add some lwm2m api (#6047) 2021-11-10 14:20:33 +08:00
zhongwencool 2d159ad9a1
fix(test): flaky mqtt expiry test case. (#6099) 2021-11-10 09:55:36 +08:00
JimMoen ac23214447
fix(api): config api on sepcific node (#6100)
* fix(api): config api on sepcific node

* chore(style):  code style for elvis checking
2021-11-10 09:38:45 +08:00
zhongwencool eea789451b
feat: sha3_256 dashboard account's password (#6084) 2021-11-09 15:41:28 +08:00
Ilya Averyanov 0f8ad29e91
Merge pull request #6078 from savonarola/auth-api-schema-examples
refactor(authn api): add more schema examples
2021-11-08 19:44:02 +03:00
zhongwencool b873b92717
fix(test): cluster_rpc retry interval incorrect (#6038) 2021-11-08 23:23:17 +08:00
k32 5726444645
Merge pull request #6066 from k32/remove-nosuspend-5
fix(emqx_connection): Add backpressure to TCP connections
2021-11-08 13:39:38 +01:00
Ilya Averyanov a84b84aac9 refactor(authn api): reformat for elvis compliance 2021-11-05 19:36:26 +03:00
Ilya Averyanov 1e036bf74d refactor(authn api): add more schema examples 2021-11-05 16:12:14 +03:00
Zaiming (Stone) Shi 3b02366a5b
Merge pull request #6064 from zmstone/style-check-newline-at-eof
Style: check newline at EOF
2021-11-04 18:01:45 +01:00
k32 0a5a9bd7d0 fix(emqx_connection): Add backpressure to TCP connections
Fixes #5494
2021-11-04 16:24:47 +01:00
Zaiming Shi d1abb30818 ci: fix elvis check 2021-11-04 15:27:10 +01:00
Zaiming Shi 56e2a9741f style: ensure newline at EOF for all files 2021-11-04 14:40:14 +01:00
zhouzb 48ddd056b5 test(authn): add test cases for authn 2021-11-04 10:03:34 +08:00
zhouzb ca4bb100ec fix(authn): fix bad parsing for postgresql SQL 2021-11-04 10:01:54 +08:00
Ilya Averyanov aed9ad3f7d
Merge pull request #6037 from savonarola/fix-authn-api-atom-leak
fix(authn api): eliminate possible atom leak
2021-11-03 23:17:47 +03:00
Zaiming Shi a139a0d453 fix(config): pin hocon 0.20.6
fix translation error
2021-11-03 11:15:35 +01:00
Tobias Lindahl 89cd68d36f refactor(persistent_sessions): fix coding style 2021-11-02 09:33:54 +01:00
Tobias Lindahl 8385eff98e fix(persistent_sessions): we only need to persist if the session expired 2021-11-02 09:27:50 +01:00
Tobias Lindahl b7ed649185 test(persistent_session): wait in test to avoid race 2021-11-01 14:56:10 +01:00
Ilya Averyanov 796553b5ea fix(authn api): eliminate possible atom leak 2021-11-01 16:51:48 +03:00
Tobias Lindahl ce49a281ed fix(persistent_sessions): protect against looking up stale data 2021-11-01 14:21:01 +01:00
Tobias Lindahl 329dd4d780 test(persistent_session): try to fix flaky snabbkaffe failure 2021-11-01 14:21:01 +01:00
Tobias Lindahl 1f13a6caad chore(persistent_sessions): tune mnesia parameters for better dump behavior 2021-11-01 14:21:01 +01:00
Tobias Lindahl ec68d7fc58 test(persistent_sessions): stabilize flaky tests 2021-11-01 14:21:01 +01:00
Tobias Lindahl 7ae6e04582 fix(persistent_sessions): channels can terminate without a session 2021-11-01 14:21:01 +01:00
zhouzb 29fb9b3361 fix(authn): fix bad type of hash 2021-11-01 18:49:13 +08:00
Ilya Averyanov 800b4b32c7
refactor(authn api): use config schemas for request validations (#5999) 2021-11-01 17:52:03 +08:00
JimMoen d9cb0283f3 fix(alarm): duration unit in dashboard, microsecond => millisecond 2021-10-29 16:48:13 +08:00
zhouzb c64637ca39 test(authn): add test case of version checking 2021-10-29 14:18:25 +08:00
zhouzb 966348db05 fix(authn): fix version switching error when updating multiple times 2021-10-29 10:12:29 +08:00
zhongwencool e62fde321c
Emqx alarm (#5994)
* chore(alarm): normalize_message outside emqx_alarm

* chore(alarm): don't cache config in emqx_alarm; remove dirty_write/read; add desc/example to alarm; add more test

* chore(alarm_api): alarm_api with hocon schema

* fix: activted's nullable is true

* fix(swagger): translate map to object

* fix(cluster_rpc): debug failed cluster_rpc test

* fix: Update schema description

Co-authored-by: Zaiming (Stone) Shi <zmstone@gmail.com>

Co-authored-by: Zaiming (Stone) Shi <zmstone@gmail.com>
2021-10-28 18:03:51 +08:00
William Yang 2c69c00906
Merge pull request #6010 from qzhuyan/perf/William/pool-worker-pickup
During the benchmark test of ehttpc, we found the gproc's random pool or round-robin pool doesn't scale well.

This PR makes emqx prefer to use the hash pool.

changed:

retainer pool: from random to hash
connector : from random to hash (default)
bridge : from random to hash (default)
authn_http : from random to hash (example)

unchanged:
worker pool type: hash
broker pool type: hash
resource type: hash
exproto type: hash
dashboard type: hash
2021-10-28 09:40:14 +02:00
Tobias Lindahl 48c7788d6f
Merge pull request #5875 from emqx/extend-persistent-sessions
Extend persistent sessions
2021-10-27 09:12:13 +02:00
zhouzb a712daaebc fix(authn): fix bad list comprehension 2021-10-27 15:08:02 +08:00
William Yang 5e6dab435a perf(pool): authz http example pool_type to hash 2021-10-27 08:48:41 +02:00
William Yang 9c8cd6c437 perf(pool): change emqx_connector default pool type to hash 2021-10-27 08:47:02 +02:00
William Yang 34979c51d7 perf(config): emqx_bridge default hash pool 2021-10-27 08:45:13 +02:00
William Yang 1c93331e34 perf(pool): emqx_authn_http pool type hash 2021-10-27 08:43:34 +02:00
William Yang edc1581b4b perf(pool): change emqx_retainer_pool type to hash 2021-10-27 08:26:02 +02:00
zhouzb 7311132d49 fix(authn): fix handling of query result 2021-10-27 09:22:17 +08:00
Zaiming (Stone) Shi 4dbe3ccf71
refactor(dashboard): rename 'password' field to 'pwdhash' (#5990)
* refactor(dashboard): rename 'password' field to 'pwdhash'

rename as it is not plaintext password stored in db

* refactor(emqx_dashboard): rename records

* test(emqx_dashboard_token): add test case to cover match specs
2021-10-26 20:41:33 +08:00
Tobias Lindahl 99836b2660 fix(persistent_sessions): add back the trap_exit 2021-10-26 10:52:27 +02:00
JimMoen 4a07d5e1f3 refactor(paginate): use exported fun call `{M,F}` 2021-10-26 16:16:37 +08:00
JimMoen 3683ba13ee fix(authn): users pagination on spec listener_id and authn_id 2021-10-26 16:16:37 +08:00
JimMoen eb452bd237 feat(authn_scram): authn_scram users page query 2021-10-26 16:16:37 +08:00
JimMoen 0bd5cd9336 feat(authn): authn users page query 2021-10-26 16:16:37 +08:00
JimMoen a399ac20e9 fix(authn): api description using binary string 2021-10-26 16:16:37 +08:00
Tobias Lindahl 558416af1d chore(persistent_sessions): remove redundant trap_exit flag 2021-10-26 10:01:02 +02:00
Tobias Lindahl 28417ad1d7 fix(persistent_sessions): allow for some failures of workers 2021-10-26 09:55:57 +02:00
Tobias Lindahl 234641ccf4 refactor(persistent_sessions): don't start session sup when disabled 2021-10-26 09:54:41 +02:00
Tobias Lindahl e3dc9b3f4f fix(persistent_sessions): start the message gc timer 2021-10-26 09:53:49 +02:00
Tobias Lindahl f39ccfb304 chore(persistent_sessions): address review comments 2021-10-26 09:53:18 +02:00
JimMoen c5142a6d11 fix(authz): add license headers 2021-10-26 14:30:39 +08:00
JimMoen f44bda806a chore(authz): fix test suite page params 2021-10-26 14:02:19 +08:00
JimMoen be6ba14ddf fix(authz): authz rules page query 2021-10-26 14:02:19 +08:00
JianBo He b36865e970 fix(api): escape the searching string 2021-10-26 10:34:03 +08:00
Zaiming (Stone) Shi 666b319729
Merge pull request #5989 from zmstone/refactor-ssl-certs-lib
refactor(tls): move ssl files handling to emqx_tls_lib
2021-10-25 12:42:29 +02:00
Zaiming (Stone) Shi a0e77d22b0
fix: typo in apps/emqx_authz/src/emqx_authz.erl
Co-authored-by: Rory Z <Rory-Z@outlook.com>
2021-10-25 08:57:44 +02:00
zhanghongtong 3c2292e74f chore(authz): add more test case 2021-10-25 13:43:28 +08:00
zhanghongtong a2da746bf9 chore(authz): implement create_dry_run in other function clause
Signed-off-by: zhanghongtong <rory-z@outlook.com>
2021-10-25 13:43:28 +08:00
zhanghongtong 2307bdd868 fix(emqx_resource): fix InstId type error 2021-10-25 13:43:28 +08:00
zhanghongtong 198ae4c782 fix(authz): fix configuration could be updated with incorrect values
when updating the configuration, first check with emqx_resouce:create_dry_run/2

Signed-off-by: zhanghongtong <rory-z@outlook.com>
2021-10-25 13:43:28 +08:00
tigercl 0d53ea9db7
Merge pull request #5974 from tigercl/fix/mysql-query
fix(authn): fix sql parse for mysql
2021-10-25 10:38:15 +08:00
Zaiming Shi a7413bc11e fix(authn): save certificates to certs dir 2021-10-24 16:21:57 +02:00
Zaiming Shi 71d2e6bebd refactor(authz): call emqx_tls_lib to save & read SSL files 2021-10-24 10:44:47 +02:00
Zaiming Shi a7771afd9d refactor(tls): move ssl files handling to emqx_tls_lib
This is an attempt ot make it more generic for other APPs to use.
Aslo added test cases to cover most of the code paths.
2021-10-23 18:20:38 +02:00
firest d0950b9b9d fix(emqx_telemetry): add default value to get_value 2021-10-23 00:24:07 +08:00
Zaiming (Stone) Shi bdeb1685e0
Merge pull request #5977 from zmstone/chore-pin-hocon-0.20.5
Pin hocon 0.20.5
2021-10-22 16:36:12 +02:00
zhongwencool 90795a6f42
Rewrite http api with hocon schema (#5980)
* feat: rewrite http api with hocon

* fix: crash when default_username is empty

* chore: udpate rewrite api with emqx_conf's cluster_rpc

* fix: spec wrong
2021-10-22 17:01:29 +08:00
Zaiming Shi 0937c81632 test: fix emqx_config_SUITE 2021-10-22 09:45:01 +02:00
Tobias Lindahl 64787f4ccd test(persistent_session): fix bad guard 2021-10-22 01:03:08 +02:00
Tobias Lindahl 10de564abf test(persistent_sessions): test websocket connection 2021-10-22 00:46:58 +02:00
Zaiming Shi aa6053291e fix(schema): add roots for emqx_zone_schema
emqx_zone_schema is never used at root level, but for config doc
generation, it needs the roots.
2021-10-21 23:11:02 +02:00
Zaiming Shi b03b0717ce docs: authenticator_config ref link to the struct 2021-10-21 23:11:02 +02:00
Zaiming Shi f9b211cce6 chore: pin hocon 0.20.5
for two changes:
default string values are filled with binary() instead of [integer()]
better reference links in config document
2021-10-21 23:09:51 +02:00
Tobias Lindahl 9188f5b67e fix(persistent_sessions): postpone table creation until configs are loaded 2021-10-21 15:23:22 +02:00
Tobias Lindahl fe4d14303c fix(persistent_session): fix rebase error 2021-10-21 15:23:22 +02:00
Tobias Lindahl ec429857e0 refactor(persistent_sessions): code format changes after review 2021-10-21 15:23:21 +02:00
Tobias Lindahl 655d31726a feat(persistent_session): add early removal of delivered message 2021-10-21 15:23:21 +02:00
Tobias Lindahl b9b8111edb test: add new proper types to #session{} after rebase 2021-10-21 15:23:21 +02:00
Tobias Lindahl fd71bc50ab fix(persistent_session): Make sure to discard expired sessions on reconnect 2021-10-21 15:23:21 +02:00
Tobias Lindahl f2d26f5e03 test(persistent_sessions): Remove bogus stopping of quicer 2021-10-21 15:23:21 +02:00
Tobias Lindahl 12639addb9 fix(persistent_session): Make sure the connection processs is dead 2021-10-21 15:23:21 +02:00
Tobias Lindahl ed0f435546 chore(persistent_sessions): correct copyright information in new files 2021-10-21 15:23:21 +02:00
Tobias Lindahl fdba441f4f fix(persistent_sessions): revert bogus table type change 2021-10-21 15:23:21 +02:00
Tobias Lindahl 7808ffe600 fix(persistent_sessions): protect (un)subscribe from calling session router 2021-10-21 15:23:21 +02:00
Tobias Lindahl 7b394267dd feat: persistent sessions stored in mnesia
* Persistent sessions can survive node/connection process down
* Internal SessionID is generated, external ClientID is as before
* Sessions are persisted to mnesia
* A session router is added in parallel to the ordinary router
* Messages that are subscribed to by a persistent session are
  persisted by publisher
* Information about persisted and delivered messages are stored in
  mnesia per session.
* A resume protocol similar to takeover is implemented for resuming
  from mnesia
* Can be configured (and enabled) by the top lever config
  "persistent_session_store"
2021-10-21 15:23:21 +02:00
Tobias Lindahl fc7b4c0009 refactor: make it possible to use different tries
In preparation for persistent sessions
2021-10-21 15:23:21 +02:00
Tobias Lindahl 24e870672c refactor: use set_session in preparation for persistent sessions 2021-10-21 15:23:21 +02:00
Ilya Averyanov e37ecc10a6 style(behaviour attrs): unify behaviour declarations 2021-10-21 15:10:59 +03:00
zhongwencool d784e63b9f
emqx_conf (#5939)
* feat(emqx_conf): move conf manager for emqx_machine to emqx_conf

* chore(emqx_conf): change emqx:get_config/2 to emqx_conf:get/2

* fix: common test failed

* fix: badmatch by typo wrong key

* fix(emqx_conf): get the wrong core nodes

* fix(emqx_conf): get core node's tnx_id not latest tnx_id

* fix: add ro_transation when copy conf file

* fix: delete debug info

* fix: change ekka_rlog to mria_rlog

* fix: remove cluster_rpc from emqx_machine.

* fix: don't call ekka:start/0 explicitly

* fix: ekka should be start in emqx_machine
2021-10-21 18:08:51 +08:00
zhouzb 7fdcca587a fix(authn): fix handling of pgsql response 2021-10-21 17:41:16 +08:00
zhouzb e071a10fee fix(authn): no longer use single quotes to wrap placeholders 2021-10-21 17:14:08 +08:00
zhouzb 3a834a822f fix(authn): fix sql parse for mysql 2021-10-21 17:07:24 +08:00
k32 9fdd5e6a7e
fix(emqx_machine): Fix start/stop callbacks (#5969)
* fix(emqx_machine): Fix start/stop callbacks

* chore(ekka): Bump version to 0.11.1

* fix(router): Wait for the tables

* fix(emqx_cluster_rpc): Stop cluster RPC when joining a cluster

* fix(emqx_app): Fix a deadlock when joining the cluster

* fix(emqx_telemetry): Wait for mnesia tables

* test(ct_helper): Start ekka before emqx
2021-10-21 14:49:21 +08:00
Zaiming (Stone) Shi ed069cfecc
Merge pull request #5963 from zmstone/refactor-authn-schema
refactor(authn): check authenticator config with provider module
2021-10-21 08:07:48 +02:00
tigercl 45b484a26a
Merge pull request #5967 from tigercl/fix/authn-mysql
fix(authn): fix placeholders are not replaced correctly
2021-10-21 10:20:05 +08:00
zhouzb ef731c74eb chore(deps): unify version of hocon 2021-10-21 09:35:00 +08:00
William Yang 7b3537d822
Merge pull request #5966 from qzhuyan/dev/william/lc-0.1.2
feat(olp): bump to 0.1.2
2021-10-20 21:57:31 +02:00
Zaiming Shi ce5b456872 refactor(authn): make schema doc generation work 2021-10-20 17:42:06 +02:00
Zaiming Shi fa91e5f583 fix(authn): allow single authenticator instance from config 2021-10-20 15:06:08 +02:00
Zaiming Shi d468c21e61 fix(authn): rename config key http-server to http 2021-10-20 14:36:37 +02:00
Zaiming Shi 019b9d17f6 refactor(emqx_config_handler): async remove 2021-10-20 14:12:46 +02:00
k32 8e58699ff5
Merge pull request #5937 from k32/mria
feat(mria): Replace ekka_mnesia with mria
2021-10-20 13:15:23 +02:00
Zaiming Shi 88d891a59a feat: support check_config callback for authenticator provider 2021-10-20 13:04:55 +02:00
Zaiming Shi 72c26931d7 fix: fill string fields' default value with binary 2021-10-20 11:52:30 +02:00
Zaiming Shi 1b9c082563 refactor(authn): check authenticator config with provider module
mainly two changes:

1. the schema is simplified at root level, per-authenticator checks
   are done after the type can be identified
2. the config handling part is split out from emqx_authentication
   module to emqx_authentication_config module
2021-10-20 10:13:11 +02:00
Zaiming (Stone) Shi e2f9b111b6
Merge pull request #5944 from Spycsh/slog
chore: change to structured logging under apps/emqx/authz and authn
2021-10-20 07:25:40 +02:00
JianBo He 9d4268e5e6 test(gw): ensure subscription established 2021-10-20 10:40:35 +08:00
JianBo He 7c04dbc585 test(gw): eliminate side effect between tests 2021-10-20 10:40:35 +08:00
JianBo He 69df027ee9 chore(gw): use SLOG to replace LOG 2021-10-20 10:40:35 +08:00
JianBo He 2416fa4e13 chore(gw): return 204 if no authn config 2021-10-20 10:40:35 +08:00
JianBo He 46e0609544 test(gw): add clients HTTP-API tests 2021-10-20 10:40:35 +08:00