| | 105 | === MySQL |
|---|
| | 106 | |
|---|
| | 107 | Lets set up a simple server requiring authentication against a MySQL |
|---|
| | 108 | database to fetch any content. |
|---|
| | 109 | |
|---|
| | 110 | First, lets define a unique rule in our virtual server managed by the |
|---|
| | 111 | `List and Send` handler. Through the `Security` tab we can configure |
|---|
| | 112 | it to use MySQL as authentication mechanism. Filling up just the |
|---|
| | 113 | essential fields will be enough. Realm, database name, user, password |
|---|
| | 114 | and an SQL query that must return one row with one column as password. |
|---|
| | 115 | |
|---|
| | 116 | image::media/images/cookbook_mysql_validator.png[MySQL handler set up] |
|---|
| | 117 | |
|---|
| | 118 | In this case, we have used: |
|---|
| | 119 | |
|---|
| | 120 | ---- |
|---|
| | 121 | SELECT password FROM auth_users WHERE username = '${user}' |
|---|
| | 122 | ---- |
|---|
| | 123 | |
|---|
| | 124 | And that is about it. |
|---|
| | 125 | In this example you will need a MySQL server running (localhost in |
|---|
| | 126 | this case, as it takes the default value), a database called |
|---|
| | 127 | `cherokee` with `cherokee` as user and password, and a table that |
|---|
| | 128 | suits the shown query. |
|---|
| | 129 | |
|---|
| | 130 | When we are done, our simple virtual server should look like this: |
|---|
| | 131 | |
|---|
| | 132 | image::media/images/cookbook_mysql_rule.png[MySQL Authenticated rule] |
|---|
| | 133 | |
|---|
| | 134 | And any content requested to Cherokee will require prior |
|---|
| | 135 | authentication agains the database. |
|---|
| | 136 | |
|---|