|
1 | 1 | # Integrate with Redis |
2 | 2 |
|
3 | | -EMQX supports integrating with Redis for password authentication. EMQX Redis authenticator currently supports connecting to running in three different modes, which are Single, [Redis Sentinel](https://redis.io/docs/manual/sentinel/) and [Redis Cluster](https://redis.io/docs/manual/scaling/). This section gives detailed instructions on the data schema supported and on how to configure with EMQX Dashboard and configuration file. |
| 3 | +EMQX supports integrating with Redis for password authentication. EMQX Redis authenticator currently supports connecting to Redis running in three different modes, which are Single, [Redis Sentinel](https://redis.io/docs/manual/sentinel/), and [Redis Cluster](https://redis.io/docs/manual/scaling/). This section gives detailed instructions on the data schema supported and on how to configure with EMQX Dashboard and the configuration file. |
4 | 4 |
|
5 | 5 | ::: tip Prerequisite: |
6 | 6 |
|
@@ -51,37 +51,56 @@ You can use EMQX Dashboard to configure how to use Redis for password authentica |
51 | 51 |
|
52 | 52 | <img src="./assets/authn-redis.png" alt="Authentication with redis" style="zoom:67%;" /> |
53 | 53 |
|
54 | | -4. Follow the instructions below to configure the authentication backend: |
55 | | - |
56 | | - - Enter the information for connecting to Redis. |
57 | | - |
58 | | - - **Redis Mode**: Select how Redis is deployed, including `Single`, `Sentinel` and `Cluster`. |
59 | | - - **Server(s)**: Specify the Redis server address that EMQX is to connect, if **Redis Mode** is set to `Sentinel` or `Cluster`, you will need to input all Redis servers (separated with a `,`) that EMQX is to connect. |
60 | | - - **Sentinel Name**: Specify the name to use; type: strings; only needed if you set **Redis Mode** to `Sentinel`. |
61 | | - - **Database**: Redis database name; Data type: strings. |
62 | | - - **Password**: Specify Redis user password. |
63 | | - - Configure settings related to authentication: |
64 | | - |
65 | | - - **Password Hash**: Select the password hashing algorithm applied to plain-text passwords before results are stored in the database. Available options are `plain`, `md5`, `sha`, `sha256`, `sha512`, `bcrypt`, and `pbkdf2`. Additional configurations depend on the selected algorithm: |
66 | | - - For `md5`, `sha`, `sha256` or `sha512`: |
67 | | - - **Salt Position**: Determines how salt (random data) is mixed with the password. Options are `suffix`, `prefix`, or `disable`. You can keep the default value unless you migrate user credentials from external storage into the EMQX built-in database. |
68 | | - - Resulting hash is represented as a string of hexadecimal characters, and compared case-insensitively with the stored credential. |
69 | | - - For `plain`: |
70 | | - - **Salt Position**: should be `disable`. |
71 | | - - For `bcrypt`: |
72 | | - - **Salt Rounds**: Defines the number of times the hash function is applied, expressed as _2<sup>Salt Rounds</sup>_, also known as the "cost factor". The default value is `10`, with a permissible range of `5` to `10`. A higher value is recommended for enhanced security. Note: Increasing the cost factor by 1 doubles the necessary time for authentication. |
73 | | - - For `pbkdf2`: |
74 | | - - **Pseudorandom Function**: Selects the hash function that generates the key, such as `sha256`. |
75 | | - - **Iteration Count**: Sets the number of times the hash function is executed. The default is `4096`. |
76 | | - - **Derived Key Length** (optional): Specifies the length in bytes of the generated key. If left blank, the length will default to that determined by the selected pseudorandom function. |
77 | | - - Resulting hash is represented as a string of hexadecimal characters, and compared case-insensitively with the stored credential. |
78 | | - - **Precondition**: A [Variform expression](../../configuration/configuration.md#variform-expressions) used to control whether this Redis authenticator should be applied to a client connection. The expression is evaluated against attributes from the client (such as `username`, `clientid`, `listener`, etc.). The authenticator will only be invoked if the expression evaluates to the string `"true"`. Otherwise, it will be skipped. For more information about the precondition, see [Authenticator Preconditions](./authn.md#authenticator-preconditions). |
79 | | - - **Enable TLS**: Turn on the toggle switch if you want to enable TLS. For more information on enabling TLS, see [Network and TLS](../../network/overview.md). |
80 | | - - **CMD**: Redis query command. |
81 | | - - **Advanced Settings**: |
82 | | - - **Pool size** (optional): Specify the number of concurrent connections from an EMQX node to a Redis server. Default: `8`. |
83 | | - |
84 | | -5. After you finish the settings, click **Create**. |
| 54 | +Follow the instructions below on how to configure the authentication: |
| 55 | + |
| 56 | +**Connect**: Enter the information for connecting to Redis. |
| 57 | + |
| 58 | +- **Redis Mode**: Select how Redis is deployed, including `Single`, `Sentinel` and `Cluster`. |
| 59 | + |
| 60 | +- **Server(s)**: Specify the Redis server address that EMQX is to connect, if **Redis Mode** is set to `Sentinel` or `Cluster`, you will need to input all Redis servers (separated with a `,`) that EMQX is to connect. |
| 61 | + |
| 62 | +- **Sentinel Name**: Specify the name to use; type: strings; only needed if you set **Redis Mode** to `Sentinel`. |
| 63 | + |
| 64 | +- **Database**: Redis database name; Data type: strings. |
| 65 | + |
| 66 | +- **Username**: Specify the Redis username to connect with. This field is required if your Redis instance uses [Redis ACL](https://redis.io/docs/latest/operate/oss_and_stack/management/security/acl/#create-and-edit-user-acls-with-the-acl-setuser-command) (introduced in Redis 6.0) for authentication. If your Redis server uses the default user (with ACLs disabled or not enforced), you can leave this field blank. |
| 67 | + |
| 68 | + ::: tip |
| 69 | + |
| 70 | + The `username` field is supported starting from EMQX 5.2.0. Ensure your deployment is running this version or later to use Redis ACL. |
| 71 | + |
| 72 | + ::: |
| 73 | + |
| 74 | +- **Password**: Specify the password for the Redis user. The field is required for connecting to Redis instances with authentication enabled. |
| 75 | + |
| 76 | + - If you have entered a username, this password must match the credentials configured in your Redis ACL settings. |
| 77 | + - If no username is provided, this password will be used to authenticate as the `default` user (if enabled). |
| 78 | + |
| 79 | + |
| 80 | +**TLS Configuration**: Turn on the toggle switch if you want to enable TLS. For more information on enabling TLS, see [Network and TLS](../../network/overview.md). |
| 81 | + |
| 82 | +**Connection Configuration**: Set the concurrent connections. |
| 83 | + |
| 84 | +- **Pool size** (optional): Specify the number of concurrent connections from an EMQX node to a Redis server. Default: `8`. |
| 85 | + |
| 86 | +**Authentication configuration**: Configure settings related to authentication: |
| 87 | + |
| 88 | +- **Password Hash**: Select the password hashing algorithm applied to plain-text passwords before results are stored in the database. Available options are `plain`, `md5`, `sha`, `sha256`, `sha512`, `bcrypt`, and `pbkdf2`. Additional configurations depend on the selected algorithm: |
| 89 | + - For `md5`, `sha`, `sha256` or `sha512`: |
| 90 | + - **Salt Position**: Determines how salt (random data) is mixed with the password. Options are `suffix`, `prefix`, or `disable`. You can keep the default value unless you migrate user credentials from external storage into the EMQX built-in database. |
| 91 | + - Resulting hash is represented as a string of hexadecimal characters, and compared case-insensitively with the stored credential. |
| 92 | + - For `plain`: |
| 93 | + - **Salt Position**: should be `disable`. |
| 94 | + - For `bcrypt`: |
| 95 | + - **Salt Rounds**: Defines the number of times the hash function is applied, expressed as _2<sup>Salt Rounds</sup>_, also known as the "cost factor". The default value is `10`, with a permissible range of `5` to `10`. A higher value is recommended for enhanced security. Note: Increasing the cost factor by 1 doubles the necessary time for authentication. |
| 96 | + - For `pbkdf2`: |
| 97 | + - **Pseudorandom Function**: Selects the hash function that generates the key, such as `sha256`. |
| 98 | + - **Iteration Count**: Sets the number of times the hash function is executed. The default is `4096`. |
| 99 | + - **Derived Key Length** (optional): Specifies the length in bytes of the generated key. If left blank, the length will default to that determined by the selected pseudorandom function. |
| 100 | + - Resulting hash is represented as a string of hexadecimal characters, and compared case-insensitively with the stored credential. |
| 101 | +- **CMD**: Redis query command. |
| 102 | + |
| 103 | +After you finish the settings, click **Create**. |
85 | 104 |
|
86 | 105 | ## Configure with Configuration Items |
87 | 106 |
|
|
0 commit comments