2014-11-20 17:00:54 +01:00
|
|
|
# <a id="authentication"></a> Authentication
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
**Choosing the Authentication Method**
|
|
|
|
|
2014-12-18 15:24:06 +01:00
|
|
|
With Icinga Web 2 you can authenticate against Active Directory, LDAP, a MySQL or a PostgreSQL database or delegate
|
|
|
|
authentication to the web server.
|
|
|
|
|
|
|
|
Authentication methods can be chained to set up fallback authentication methods
|
2014-11-20 17:00:54 +01:00
|
|
|
or if users are spread over multiple places.
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2014-12-18 15:24:06 +01:00
|
|
|
## <a id="authentication-configuration"></a> Configuration
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
Authentication methods are configured in the INI file **config/authentication.ini**.
|
|
|
|
|
|
|
|
Each section in the authentication configuration represents a single authentication method.
|
|
|
|
|
|
|
|
The order of entries in the authentication configuration determines the order of the authentication methods.
|
2014-12-18 15:24:06 +01:00
|
|
|
If the current authentication method errors or if the current authentication method does not know the account being
|
2014-11-20 17:00:54 +01:00
|
|
|
authenticated, the next authentication method will be used.
|
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
## <a id="authentication-configuration-external-authentication"></a> External Authentication
|
2014-11-20 17:00:54 +01:00
|
|
|
|
|
|
|
For delegating authentication to the web server simply add `autologin` to your authentication configuration:
|
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
```
|
2014-11-20 17:00:54 +01:00
|
|
|
[autologin]
|
2015-01-27 09:49:36 +01:00
|
|
|
backend = external
|
2016-03-30 16:03:53 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
If your web server is not configured for authentication though, the `autologin` section has no effect.
|
|
|
|
|
|
|
|
### <a id="authentication-configuration-external-authentication-example"></a> Example Configuration for Apache and Basic Authentication
|
|
|
|
|
|
|
|
The following example will show you how to enable external authentication in Apache
|
|
|
|
using **Basic access authentication**.
|
|
|
|
|
|
|
|
**Creating Users**
|
|
|
|
|
|
|
|
To create users for **basic access authentication** you can use the tool `htpasswd`. In this example **.http-users** is
|
|
|
|
the name of the file containing the user credentials.
|
|
|
|
|
|
|
|
The following command creates a new file with the user **icingaadmin**. `htpasswd` will prompt you for a password.
|
|
|
|
If you want to add more users to the file you have to omit the `-c` switch to not overwrite the file.
|
|
|
|
|
|
|
|
```
|
|
|
|
sudo htpasswd -c /etc/icingaweb2/.http-users icingaadmin
|
|
|
|
```
|
|
|
|
|
|
|
|
**Configuring the Web Server**
|
|
|
|
|
|
|
|
Add the following configuration to the **<Directory> Directive** in the **icingaweb.conf** web server
|
|
|
|
configuration file.
|
|
|
|
|
|
|
|
```
|
|
|
|
AuthType Basic
|
|
|
|
AuthName "Icinga Web 2"
|
|
|
|
AuthUserFile /etc/icingaweb2/.http-users
|
|
|
|
Require valid-user
|
|
|
|
```
|
2014-11-20 17:00:54 +01:00
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
Restart your web server to apply the changes.
|
2014-11-20 17:00:54 +01:00
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
## <a id="authentication-configuration-ad-or-ldap-authentication"></a> Active Directory or LDAP Authentication
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
If you want to authenticate against Active Directory or LDAP, you have to define a
|
2016-04-13 13:43:39 +02:00
|
|
|
[LDAP resource](04-Resources.md#resources-configuration-ldap) which will be referenced as data source for the
|
2016-03-30 16:03:53 +02:00
|
|
|
Active Directory or LDAP configuration method.
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
### <a id="authentication-configuration-ldap-authentication"></a> LDAP
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2016-09-01 14:18:29 +02:00
|
|
|
| Directive | Description |
|
|
|
|
| ------------------------- | ----------- |
|
|
|
|
| **backend** | `ldap` |
|
|
|
|
| **resource** | The name of the LDAP resource defined in [resources.ini](04-Resources.md#resources). |
|
|
|
|
| **user_class** | LDAP user class. |
|
|
|
|
| **user_name_attribute** | LDAP attribute which contains the username. |
|
|
|
|
| **filter** | LDAP search filter. |
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
**Example:**
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
```
|
|
|
|
[auth_ldap]
|
|
|
|
backend = ldap
|
|
|
|
resource = my_ldap
|
|
|
|
user_class = inetOrgPerson
|
|
|
|
user_name_attribute = uid
|
2015-08-26 17:21:51 +02:00
|
|
|
filter = "memberOf=cn=icinga_users,cn=groups,cn=accounts,dc=icinga,dc=org"
|
2014-11-20 17:00:54 +01:00
|
|
|
```
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2015-02-03 10:15:54 +01:00
|
|
|
Note that in case the set *user_name_attribute* holds multiple values it is required that all of its
|
|
|
|
values are unique. Additionally, a user will be logged in using the exact user id used to authenticate
|
|
|
|
with Icinga Web 2 (e.g. an alias) no matter what the primary user id might actually be.
|
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
### <a id="authentication-configuration-ad-authentication"></a> Active Directory
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2016-09-01 14:18:29 +02:00
|
|
|
| Directive | Description |
|
|
|
|
| ------------- | ----------- |
|
|
|
|
| **backend** | `msldap` |
|
|
|
|
| **resource** | The name of the LDAP resource defined in [resources.ini](04-Resources.md#resources). |
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
**Example:**
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
```
|
|
|
|
[auth_ad]
|
2015-08-19 09:23:17 +02:00
|
|
|
backend = msldap
|
2014-11-20 17:00:54 +01:00
|
|
|
resource = my_ad
|
|
|
|
```
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
## <a id="authentication-configuration-db-authentication"></a> Database Authentication
|
2013-08-13 18:08:21 +02:00
|
|
|
|
2014-12-18 15:24:06 +01:00
|
|
|
If you want to authenticate against a MySQL or a PostgreSQL database, you have to define a
|
2016-04-13 13:43:39 +02:00
|
|
|
[database resource](04-Resources.md#resources-configuration-database) which will be referenced as data source for the database
|
2014-11-20 17:00:54 +01:00
|
|
|
authentication method.
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2016-09-01 14:18:29 +02:00
|
|
|
| Directive | Description |
|
|
|
|
| ------------------------| ----------- |
|
|
|
|
| **backend** | `db` |
|
|
|
|
| **resource** | The name of the database resource defined in [resources.ini](04-Resources.md#resources). |
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
**Example:**
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
```
|
2015-05-06 23:02:52 +02:00
|
|
|
[auth_db]
|
|
|
|
backend = db
|
2014-12-18 15:37:08 +01:00
|
|
|
resource = icingaweb-mysql
|
2014-11-20 17:00:54 +01:00
|
|
|
```
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
### <a id="authentication-configuration-db-setup"></a> Database Setup
|
2014-12-18 15:37:08 +01:00
|
|
|
|
|
|
|
For authenticating against a database, you have to import one of the following database schemas:
|
|
|
|
|
|
|
|
* **etc/schema/preferences.mysql.sql** (for **MySQL** database)
|
|
|
|
* **etc/schema/preferences.pgsql.sql** (for **PostgreSQL** databases)
|
|
|
|
|
2016-04-13 13:43:39 +02:00
|
|
|
After that you have to define the [database resource](04-Resources.md#resources-configuration-database).
|
2014-12-18 15:37:08 +01:00
|
|
|
|
2014-11-20 17:00:54 +01:00
|
|
|
**Manually Creating Users**
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2014-12-18 15:37:08 +01:00
|
|
|
Icinga Web 2 uses the MD5 based BSD password algorithm. For generating a password hash, please use the following
|
|
|
|
command:
|
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
```
|
2015-04-10 13:20:09 +02:00
|
|
|
openssl passwd -1 password
|
2016-03-30 16:03:53 +02:00
|
|
|
```
|
2014-12-18 15:37:08 +01:00
|
|
|
|
|
|
|
> Note: The switch to `openssl passwd` is the **number one** (`-1`) for using the MD5 based BSD password algorithm.
|
2013-07-25 10:05:47 +02:00
|
|
|
|
2014-12-18 15:37:08 +01:00
|
|
|
Insert the user into the database using the generated password hash:
|
|
|
|
|
2016-03-30 16:03:53 +02:00
|
|
|
```
|
2014-11-20 17:00:54 +01:00
|
|
|
INSERT INTO icingaweb_user (name, active, password_hash) VALUES ('icingaadmin', 1, 'hash from openssl');
|
2016-03-30 16:03:53 +02:00
|
|
|
```
|