| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>ProFTPD module mod_wrap2_redis</title> |
| 5 | </head> |
| 6 | |
| 7 | <body bgcolor=white> |
| 8 | |
| 9 | <hr> |
| 10 | <center> |
| 11 | <h2><b>ProFTPD module <code>mod_wrap2_redis</code></b></h2> |
| 12 | </center> |
| 13 | <hr> |
| 14 | |
| 15 | <p> |
| 16 | This submodule provides the Redis server "driver" for storing |
| 17 | IP/DNS-based access control information in Redis lists/sets. |
| 18 | |
| 19 | <p> |
| 20 | This <code>mod_wrap2</code> submodule is contained in the |
| 21 | <code>mod_wrap2_redis.c</code> file, and is not compiled by default. See the |
| 22 | <code>mod_wrap2</code> <a href="mod_wrap2.html#Installation">installation</a> |
| 23 | instructions. |
| 24 | |
| 25 | <h2>Author</h2> |
| 26 | <p> |
| 27 | Please contact TJ Saunders <tj <i>at</i> castaglia.org> with any |
| 28 | questions, concerns, or suggestions regarding this module. |
| 29 | |
| 30 | <p> |
| 31 | <hr><h2><a name="RedisListsSets">Redis Access Lists/Sets</a></h2> |
| 32 | The <code>mod_wrap2_redis</code> module supports the "redis" string |
| 33 | for the <em>source-type</em> parameter of the |
| 34 | <a href="mod_wrap2.html#WrapUserTables"><code>WrapUserTables</code></a>, |
| 35 | <a href="mod_wrap2.html#WrapGroupTables"><code>WrapGroupTables</code></a>, |
| 36 | and |
| 37 | <a href="mod_wrap2.html#WrapTables"><code>WrapTables</code></a>, |
| 38 | configuration directives. If the "redis" <em>source-type</em> is used, |
| 39 | then the <em>source-info</em> parameter must be as described below. Note |
| 40 | that support for Redis-based lists/sets <b>requires</b> the use of |
| 41 | <code>mod_redis</code> (<i>e.g.</i> via the <code>--enable-redis</code> |
| 42 | configure option). |
| 43 | |
| 44 | <p> |
| 45 | <code>mod_wrap2_redis</code> requires only that the |
| 46 | <a href="../modules/mod_redis.html"><code>mod_redis</code></a> module be |
| 47 | enabled and configured to access a Redis server. |
| 48 | |
| 49 | <p> |
| 50 | One Redis list (or set) is needed to retrieving access information from the |
| 51 | <em>allow</em> "table", and another list/set for access information from the |
| 52 | <em>deny</em> "table". These lists/sets should contain a list of words, |
| 53 | where each word is a host name, host address, pattern, or wildcard (see |
| 54 | <a href="mod_wrap2.html#AccessRules">here</a> for how these things are |
| 55 | defined). |
| 56 | |
| 57 | <p> |
| 58 | Optionally, other Redis lists/sets can be defined to look up access |
| 59 | <a href="mod_wrap2.html#AccessOptions">options</a> from the <em>allow</em> and |
| 60 | <em>deny</em> tables. |
| 61 | |
| 62 | <p> |
| 63 | For Redis lists, the format for the <code>WrapUserTables</code>, |
| 64 | <code>WrapGroupTables</code>, and <code>WrapTables</code> directives is: |
| 65 | <pre> |
| 66 | WrapTables redis:/<i><b>list:</b><code>allow-list-key</code></i>[/<i><b>list:</b><code>allow-list-options-key</code></i>] \ |
| 67 | redis:<i><b>list:</b><code>deny-list-key</code></i>[/<i><b>list:</b><code>deny-list-options-key</code></i>] |
| 68 | </pre> |
| 69 | where the <i>allow-list-options-key</i> and <i>deny-list-options-key</i> |
| 70 | portions of the string are optional. |
| 71 | |
| 72 | <p> |
| 73 | For Redis <em>sets</em>, the format is similar to the above, only you specify |
| 74 | a key prefix of "set:" rather than "list", <i>e.g.</i>: |
| 75 | <pre> |
| 76 | WrapTables redis:/<i><b>set:</b><code>allow-set-key</code></i>[/<i><b>set:</b><code>allow-set-options-key</code></i>] \ |
| 77 | redis:<i><b>set:</b><code>deny-set-key</code></i>[/<i><b>set:</b><code>deny-set-options-key</code></i>] |
| 78 | </pre> |
| 79 | |
| 80 | <p> |
| 81 | <b>Redis Access Lists/Sets Example</b><br> |
| 82 | Here are example directives to help demonstrate how the <code>mod_redis</code> |
| 83 | hooks are used by <code>mod_wrap2_redis</code>. |
| 84 | These example directives assume the existence of two lists: a |
| 85 | <code>wrapallow</code> list that defines allowed clients, and a |
| 86 | <code>wrapdeny</code> list that defines the denied clients. |
| 87 | |
| 88 | <p> |
| 89 | <pre> |
| 90 | # Using Redis lists |
| 91 | WrapTables redis:/list:wrapallow redis:/list:wrapdeny |
| 92 | |
| 93 | # Using Redis sets |
| 94 | WrapTables redis:/set:wrapallow redis:/set:wrapdeny |
| 95 | </pre> |
| 96 | |
| 97 | <p> |
| 98 | For per-user/per-group lists/sets, the key name can use the <code>%{name}</code> |
| 99 | variable, like so: |
| 100 | <pre> |
| 101 | WrapUserTables * redis:/list:wrapallow.%{name} redis:/list:wrapdeny.%{name} |
| 102 | WrapGroupTables * redis:/list:wrapallow.%{name} redis:/list:wrapdeny.%{name} |
| 103 | </pre> |
| 104 | In the case of <code>WrapUserTables</code>, the <code>%{name}</code> variable |
| 105 | will be resolved to the user name (from the <code>USER</code> command) of the |
| 106 | logging-in user; for <code>WrapGroupTables</code>, <code>%{name}</code> will be |
| 107 | resolved to the name of the user's primary group. |
| 108 | |
| 109 | <p> |
| 110 | If the administrator wants to make use of access options, then URIs for those |
| 111 | options would need to be similarly defined: |
| 112 | <pre> |
| 113 | # Access tables for users (with options) |
| 114 | WrapUserTables user1,user2 \ |
| 115 | redis:/list:allowed.%{name}/list:allowed-options.%{name} \ |
| 116 | redis:/list:denied.%{name}/list:denied-options.%{name} |
| 117 | |
| 118 | # Access tables for groups (with options) |
| 119 | WrapGroupTables group1,group2 \ |
| 120 | redis:/list:allowed.%{name}/list:allowed-options.%{name} \ |
| 121 | redis:/list:denied.%{name}/list:denied-options.%{name} |
| 122 | |
| 123 | # Access tables for everyone else (without options) |
| 124 | WrapTables redis:/list:allowed redis:/list:denied |
| 125 | </pre> |
| 126 | |
| 127 | <p> |
| 128 | When constructing the client and options lists to return to |
| 129 | <code>mod_wrap2</code>'s access control engine, <code>mod_wrap2_redis</code> |
| 130 | will parse each returned item separately, handling both comma- and space-limited |
| 131 | names in an item, into client list items. This means that the administrator can |
| 132 | store multiple client and option tokens in multiple items, as in the above |
| 133 | schema, or the administrator can choose to store all of the clients and/or |
| 134 | options in a single item, in an appropriately formatted string. |
| 135 | |
| 136 | <p> |
| 137 | <hr> |
| 138 | <font size=2><b><i> |
| 139 | © Copyright 2017 TJ Saunders<br> |
| 140 | All Rights Reserved<br> |
| 141 | </i></b></font> |
| 142 | <hr> |
| 143 | |
| 144 | </body> |
| 145 | </html> |