2021-07-10 03:34:01 +08:00
# Authentication Options
2015-05-06 01:44:22 +01:00
2020-11-27 23:34:58 +01:00
LibreNMS supports multiple authentication modules along with [Two Factor Auth ](Two-Factor-Auth.md ).
2023-01-17 16:17:43 +08:00
Here we will provide configuration details for these modules. Alternatively,
you can use [Socialite Providers ](OAuth-SAML.md ) which supports a wide variety
of social/OAuth/SAML authentication methods.
2015-05-06 01:44:22 +01:00
2021-07-10 03:34:01 +08:00
## Available authentication modules
2015-05-06 01:44:22 +01:00
2017-09-13 13:51:39 -05:00
- MySQL: [mysql ](#mysql-authentication )
2015-05-06 01:44:22 +01:00
2017-09-13 13:51:39 -05:00
- Active Directory: [active_directory ](#active-directory-authentication )
2015-05-06 01:44:22 +01:00
2017-09-13 13:51:39 -05:00
- LDAP: [ldap ](#ldap-authentication )
2015-10-22 09:13:42 +02:00
2017-09-13 13:51:39 -05:00
- Radius: [radius ](#radius-authentication )
2015-05-06 01:44:22 +01:00
2019-09-09 05:48:35 -05:00
- HTTP Auth: [http-auth ](#http-authentication ),
[ad_authorization ](#http-authentication-ad-authorization ),
[ldap_authorization ](#http-authentication-ldap-authorization )
2015-12-13 15:51:15 +00:00
2017-11-29 02:40:17 +00:00
- Single Sign-on: [sso ](#single-sign-on )
2019-09-09 05:48:35 -05:00
⚠️ **When enabling a new authentication module, the local users will no
longer be available to log in.**
2019-01-31 04:02:18 +01:00
2021-07-10 03:34:01 +08:00
## Enable authentication module
2017-09-13 13:51:39 -05:00
2019-09-09 05:48:35 -05:00
To enable a particular authentication module you need to set this up
in config.php. Please note that only ONE module can be
2020-12-30 09:38:14 -05:00
enabled. LibreNMS doesn't support multiple authentication mechanisms at
2019-09-09 05:48:35 -05:00
the same time.
2017-09-13 13:51:39 -05:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/general"
```bash
lnms config:set auth_mechanism mysql
```
2017-09-13 13:51:39 -05:00
2021-07-10 03:34:01 +08:00
## User levels and User account type
2015-05-06 01:44:22 +01:00
2019-09-09 05:48:35 -05:00
- 1: **Normal User ** : You will need to assign device / port
permissions for users at this level.
2015-05-06 01:44:22 +01:00
2019-09-09 05:48:35 -05:00
- 5: **Global Read ** : Read only Administrator.
2015-05-06 01:44:22 +01:00
2019-07-11 16:47:52 -04:00
- 10: **Administrator ** : This is a global read/write admin account.
2015-05-06 01:44:22 +01:00
2019-09-09 05:48:35 -05:00
- 11: **Demo Account ** : Provides full read/write with certain
restrictions (i.e can't delete devices).
**Note** Oxidized configs can often contain sensitive data. Because of
that only Administrator account type can see configs.
2017-11-25 15:21:45 -06:00
2021-07-10 03:34:01 +08:00
## Note for SELinux users
2015-05-06 01:44:22 +01:00
2019-09-09 05:48:35 -05:00
When using SELinux on the LibreNMS server, you need to allow Apache
(httpd) to connect LDAP/Active Directory server, this is disabled by
default. You can use SELinux Booleans to allow network access to LDAP
resources with this command:
2016-09-09 16:18:07 +02:00
2019-10-21 02:47:40 +02:00
```bash
2016-09-09 16:18:07 +02:00
setsebool -P httpd_can_connect_ldap=1
```
2021-07-10 03:34:01 +08:00
## Testing authentication
2019-09-09 05:48:35 -05:00
2017-03-29 08:22:02 -05:00
You can test authentication with this script:
2019-09-09 05:48:35 -05:00
2019-10-21 02:47:40 +02:00
```bash
2017-03-29 08:22:02 -05:00
./scripts/auth_test.php
```
2019-09-09 05:48:35 -05:00
Enable debug output to troubleshoot issues
2017-09-13 13:51:39 -05:00
2021-07-10 03:34:01 +08:00
## MySQL Authentication
2015-05-06 01:44:22 +01:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/general"
```bash
lnms config:set auth_mechanism mysql
```
2015-05-06 01:44:22 +01:00
2023-05-11 01:05:12 +01:00
This is default option with LibreNMS so you should have already have the following configuration setup
in your environment file (.env).
2019-05-22 13:31:24 -05:00
```dotenv
DB_HOST=HOSTNAME
DB_DATABASE=DBNAME
DB_USERNAME=DBUSER
DB_PASSWORD="DBPASS"
2015-05-06 01:44:22 +01:00
```
2021-07-10 03:34:01 +08:00
## Active Directory Authentication
2015-05-06 01:44:22 +01:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/general"
```bash
lnms config:set auth_mechanism active_directory
```
2016-01-30 21:06:58 -05:00
2022-09-27 09:07:50 +02:00
Install __php-ldap __ or __php8.1-ldap __ , making sure to install the
2019-09-09 05:48:35 -05:00
same version as PHP.
If you have issues with secure LDAP try setting
2023-05-11 01:05:12 +01:00
!!! setting "auth/ad"
```bash
lnms config:set auth_ad_check_certificates 0
```
this will ignore certificate errors.
2017-09-13 13:51:39 -05:00
2021-07-10 03:34:01 +08:00
### Require actual membership of the configured groups
2017-09-13 13:51:39 -05:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/ad"
```bash
lnms config:set auth_ad_require_groupmembership 1
```
If you set `auth_ad_require_groupmembership` to 1, the
2019-09-09 05:48:35 -05:00
authenticated user has to be a member of the specific group.
Otherwise all users can authenticate, and will be either level 0 or
2023-05-11 01:05:12 +01:00
you may set `auth_ad_global_read` to 1 and all users will
2019-09-09 05:48:35 -05:00
have read only access unless otherwise specified.
2017-09-13 13:51:39 -05:00
2021-07-10 03:34:01 +08:00
### Old account cleanup
2017-09-13 13:51:39 -05:00
2019-09-09 05:48:35 -05:00
Cleanup of old accounts is done by checking the authlog. You will need
to set the number of days when old accounts will be purged
AUTOMATICALLY by daily.sh.
2017-09-13 13:51:39 -05:00
2023-05-11 01:05:12 +01:00
Please ensure that you set the `authlog_purge` value to be
greater than `active_directory.users_purge` otherwise old
2019-09-09 05:48:35 -05:00
users won't be removed.
2017-09-13 13:51:39 -05:00
2021-07-10 03:34:01 +08:00
### Sample configuration
2015-05-06 01:44:22 +01:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/general"
```bash
lnms config:set auth_mechanism active_directory
lnms config:set auth_ad_url ldaps://server.example.com
lnms config:set auth_ad_domain
lnms config:set auth_ad_base_dn dc=example,dc=com
lnms config:set auth_ad_check_certificates true
lnms config:set auth_ad_binduser examplebinduser
lnms config:set auth_ad_bindpassword examplepassword
lnms config:set auth_ad_timeout 5
lnms config:set auth_ad_debug false
lnms config:set active_directory.users_purge 30
lnms config:set auth_ad_require_groupmembership true
lnms config:set auth_ad_groups.ad-admingroup.level 10
lnms config:set auth_ad_groups.ad-usergroup.level 5
```
2018-03-29 05:40:27 -05:00
2019-09-09 05:48:35 -05:00
Replace `ad-admingroup` with your Active Directory admin-user group
and `ad-usergroup` with your standard user group. It is __highly
suggested__ to create a bind user, otherwise "remember me", alerting
users, and the API will not work.
2015-05-06 01:44:22 +01:00
2021-07-10 03:34:01 +08:00
### Active Directory redundancy
2015-05-06 01:44:22 +01:00
2019-09-09 05:48:35 -05:00
You can set two Active Directory servers by editing the
2023-05-11 01:05:12 +01:00
`auth_ad_url` setting like this example:
2015-05-06 01:44:22 +01:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/ad"
```bash
lnms config:set auth_ad_url "ldaps://dc1.example.com ldaps://dc2.example.com"
```
2017-09-13 13:51:39 -05:00
2021-07-10 03:34:01 +08:00
### Active Directory LDAP filters
2017-09-13 13:51:39 -05:00
You can add an LDAP filter to be ANDed with the builtin user filter (`(sAMAccountName=$username)` ).
The defaults are:
2023-05-11 01:05:12 +01:00
!!! setting "auth/ad"
```
lnms config:set auth_ad_user_filter "(objectclass=user)"
lnms config:set auth_ad_group_filter "(objectclass=group)"
```
2017-09-13 13:51:39 -05:00
2019-09-09 05:48:35 -05:00
This yields `(&(objectclass=user)(sAMAccountName=$username))` for the
user filter and `(&(objectclass=group)(sAMAccountName=$group))` for
the group filter.
2017-09-13 13:51:39 -05:00
2022-07-16 05:14:26 +02:00
### SELinux configuration
On RHEL / CentOS / Fedora, in order for LibreNMS to reach Active Directory, you need to allow LDAP requests in SELinux:
```
setsebool -P httpd_can_connect_ldap 1
```
2021-07-10 03:34:01 +08:00
## LDAP Authentication
2017-09-13 13:51:39 -05:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/general"
```bash
lnms config:set auth_mechanism ldap
```
2017-09-13 13:51:39 -05:00
2019-09-09 05:48:35 -05:00
Install __php_ldap __ or __php7.0-ldap __ , making sure to install the
same version as PHP.
2018-03-29 05:40:27 -05:00
2021-07-10 03:34:01 +08:00
### Standard config
2015-08-18 17:06:28 +00:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/ldap"
```bash
lnms config:set auth_ldap_server ldap.example.com
lnms config:set auth_ldap_suffix ',ou=People,dc=example,dc=com'
lnms config:set auth_ldap_groupbase 'ou=groups,dc=example,dc=com'
lnms config:set auth_ldap_groups.admin.level 10
lnms config:set auth_ldap_groups.pfy.level 5
lnms config:set auth_ldap_groups.support.level 1
```
2015-05-06 01:44:22 +01:00
2021-07-10 03:34:01 +08:00
### Additional options (usually not needed)
2018-03-29 05:40:27 -05:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/ldap"
```bash
lnms config:set auth_ldap_version 3
lnms config:set auth_ldap_port 389
lnms config:set auth_ldap_starttls true
lnms config:set auth_ldap_prefix 'uid='
lnms config:set auth_ldap_group 'cn=groupname,ou=groups,dc=example,dc=com'
lnms config:set auth_ldap_groupmemberattr memberUid
lnms config:set auth_ldap_groupmembertype username
lnms config:set auth_ldap_uid_attribute uidnumber
lnms config:set auth_ldap_timeout 5
lnms config:set auth_ldap_emailattr mail
lnms config:set auth_ldap_attr.uid uid
lnms config:set auth_ldap_debug false
lnms config:set auth_ldap_userdn true
lnms config:set auth_ldap_userlist_filter service=informatique
lnms config:set auth_ldap_wildcard_ou false
```
2017-09-13 13:51:39 -05:00
2021-07-10 03:34:01 +08:00
### LDAP bind user (optional)
2019-09-09 05:48:35 -05:00
If your ldap server does not allow anonymous bind, it is highly
suggested to create a bind user, otherwise "remember me", alerting
users, and the API will not work.
2023-05-11 01:05:12 +01:00
!!! setting "auth/ldap"
```bash
lnms config:set auth_ldap_binduser ldapbind
lnms config:set auth_ldap_binddn 'CN=John.Smith,CN=Users,DC=MyDomain,DC=com'
lnms config:set auth_ldap_bindpassword password
```
2017-10-30 14:28:40 -05:00
2021-07-10 03:34:01 +08:00
### LDAP server redundancy
2017-09-13 13:51:39 -05:00
2019-09-09 05:48:35 -05:00
You can set two LDAP servers by editing the
2023-05-11 01:05:12 +01:00
`auth_ldap_server` like this example:
2017-09-13 13:51:39 -05:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/ldap"
```bash
lnms config:set auth_ldap_server ldaps://dir1.example.com ldaps://dir2.example.com
```
2015-05-06 01:44:22 +01:00
An example config setup for use with Jumpcloud LDAP as a service is:
2023-05-11 01:05:12 +01:00
!!! setting "auth/ldap"
```bash
lnms config:set auth_mechanism ldap
lnms config:set auth_ldap_version 3
lnms config:set auth_ldap_server ldap.jumpcloud.com
lnms config:set auth_ldap_port 389
lnms config:set auth_ldap_prefix 'uid=';
lnms config:set auth_ldap_suffix ',ou=Users,o={id},dc=jumpcloud,dc=com'
lnms config:set auth_ldap_groupbase 'ou=Users,o={id},dc=jumpcloud,dc=com'
lnms config:set auth_ldap_groupmemberattr member
lnms config:set auth_ldap_groups.{group}.level 10
lnms config:set auth_ldap_userdn true
```
2015-05-06 01:44:22 +01:00
2019-09-09 05:48:35 -05:00
Replace {id} with the unique ID provided by Jumpcloud. Replace
{group} with the unique group name created in Jumpcloud. This field
is case sensitive.
Note: If you have multiple user groups to define individual access
2023-05-11 01:05:12 +01:00
levels replace the `auth_ldap_groups` line with the following:
2019-09-09 05:48:35 -05:00
2023-05-11 01:05:12 +01:00
!!! setting "auth/ldap"
```bash
lnms config:set auth_ldap_groups.{admin_group}.level 10]
lnms config:set auth_ldap_groups.global_readonly_group.level 5
```
2015-10-22 09:13:42 +02:00
2022-07-16 05:14:26 +02:00
### SELinux configuration
On RHEL / CentOS / Fedora, in order for LibreNMS to reach LDAP, you need to allow LDAP requests in SELinux:
```
setsebool -P httpd_can_connect_ldap 1
```
2021-07-10 03:34:01 +08:00
## Radius Authentication
2016-01-21 21:33:15 +01:00
2019-09-09 05:48:35 -05:00
Please note that a mysql user is created for each user the logs in
2022-11-09 17:10:33 +01:00
successfully. User level 1 is assigned by default to those accounts
unless radius sends a reply attribute with the correct userlevel.
You can change the default userlevel by setting
2023-05-11 01:05:12 +01:00
`radius.userlevel` to something other than 1.
2022-11-09 17:10:33 +01:00
The attribute `Filter-ID` is a standard Radius-Reply-Attribute (string) that
can be assigned a value which translates into a userlevel in LibreNMS.
The strings to send in `Filter-ID` reply attribute is * one * of the following:
- `librenms_role_normal` - Sets the value `1` , which is the normal user level.
- `librenms_role_admin` - Sets the value `5` , which is the administrator level.
- `librenms_role_global-read` - Sets the value `10` , which is the global read level.
2023-05-11 01:05:12 +01:00
LibreNMS will ignore any other strings sent in `Filter-ID` and revert to default
userlevel that is set in your config.
2016-01-21 21:33:15 +01:00
```php
2021-06-17 03:16:21 +08:00
$config['radius']['hostname'] = 'localhost';
$config['radius']['port'] = '1812';
$config['radius']['secret'] = 'testing123';
$config['radius']['timeout'] = 3;
$config['radius']['users_purge'] = 14; // Purge users who haven't logged in for 14 days.
$config['radius']['default_level'] = 1; // Set the default user level when automatically creating a user.
2016-09-09 16:18:07 +02:00
```
2022-11-09 17:10:33 +01:00
### Radius Huntgroup
Freeradius has a function called `Radius Huntgroup` which allows to send different attributes based on NAS.
This may be utilized if you already use `Filter-ID` in your environment and also want to use radius with LibreNMS.
2021-07-10 03:34:01 +08:00
### Old account cleanup
2016-09-21 13:42:59 -06:00
2019-09-09 05:48:35 -05:00
Cleanup of old accounts is done by checking the authlog. You will need
to set the number of days when old accounts will be purged
AUTOMATICALLY by daily.sh.
2016-09-21 13:42:59 -06:00
2020-12-30 09:38:14 -05:00
Please ensure that you set the `$config['authlog_purge']` value to be
greater than `$config['radius']['users_purge']` otherwise old users
2019-09-09 05:48:35 -05:00
won't be removed.
2016-09-21 13:42:59 -06:00
2021-07-10 03:34:01 +08:00
## HTTP Authentication
2016-09-21 13:42:59 -06:00
2017-09-13 13:51:39 -05:00
Config option: `http-auth`
2015-12-13 15:51:15 +00:00
2019-09-09 05:48:35 -05:00
LibreNMS will expect the user to have authenticated via your
webservice already. At this stage it will need to assign a userlevel
for that user which is done in one of two ways:
2015-12-13 15:51:15 +00:00
2017-09-13 13:51:39 -05:00
- A user exists in MySQL still where the usernames match up.
2015-12-13 15:51:15 +00:00
2017-09-13 13:51:39 -05:00
- A global guest user (which still needs to be added into MySQL:
2019-09-09 05:48:35 -05:00
2015-12-13 15:51:15 +00:00
```php
2017-09-13 13:51:39 -05:00
$config['http_auth_guest'] = "guest";
2015-12-13 15:51:15 +00:00
```
2017-09-13 13:51:39 -05:00
2019-09-09 05:48:35 -05:00
This will then assign the userlevel for guest to all authenticated users.
2016-05-20 09:47:53 +02:00
2021-07-10 03:34:01 +08:00
### HTTP Authentication / AD Authorization
2016-05-20 09:47:53 +02:00
Config option: `ad-authorization`
2021-06-17 03:16:21 +08:00
This module is a combination of ___http-auth_ __ and ___active\_directory_ __
2016-05-20 09:47:53 +02:00
2019-09-09 05:48:35 -05:00
LibreNMS will expect the user to have authenticated via your
webservice already (e.g. using Kerberos Authentication in Apache) but
will use Active Directory lookups to determine and assign the
userlevel of a user. The userlevel will be calculated by using AD
2021-06-17 03:16:21 +08:00
group membership information as the ___active\_directory_ __ module
2019-09-09 05:48:35 -05:00
does.
2021-06-17 03:16:21 +08:00
The configuration is the same as for the ___active\_directory_ __ module
2019-09-09 05:48:35 -05:00
with two extra, optional options: auth_ad_binduser and
auth_ad_bindpassword. These should be set to a AD user with read
capabilities in your AD Domain in order to be able to perform
searches. If these options are omitted, the module will attempt an
anonymous bind (which then of course must be allowed by your Active
Directory server(s)).
2016-05-20 09:47:53 +02:00
There is also one extra option for controlling user information caching: auth_ldap_cache_ttl.
2019-09-09 05:48:35 -05:00
This option allows to control how long user information (user_exists,
userid, userlevel) are cached within the PHP Session.
2016-05-20 09:47:53 +02:00
The default value is 300 seconds.
To disable this caching (highly discourage) set this option to 0.
```php
$config['auth_ad_binduser'] = "ad_binduser";
$config['auth_ad_bindpassword'] = "ad_bindpassword";
$config['auth_ldap_cache_ttl'] = 300;
```
2017-09-13 13:51:39 -05:00
2021-07-10 03:34:01 +08:00
### HTTP Authentication / LDAP Authorization
2017-09-13 13:51:39 -05:00
Config option: `ldap-authorization`
This module is a combination of ___http-auth_ __ and ___ldap_ __
2019-09-09 05:48:35 -05:00
LibreNMS will expect the user to have authenticated via your
webservice already (e.g. using Kerberos Authentication in Apache) but
will use LDAP to determine and assign the userlevel of a user. The
userlevel will be calculated by using LDAP group membership
information as the ___ldap_ __ module does.
2017-09-13 13:51:39 -05:00
2022-04-22 08:28:29 +02:00
The configuration is similar to the ___ldap_ __ module with one extra option: auth_ldap_cache_ttl.
2017-09-13 13:51:39 -05:00
This option allows to control how long user information (user_exists, userid, userlevel) are cached within the PHP Session.
The default value is 300 seconds.
To disabled this caching (highly discourage) set this option to 0.
2022-04-22 08:28:29 +02:00
#### Standard config
2017-09-13 13:51:39 -05:00
```php
2022-04-22 08:28:29 +02:00
$config['auth_mechanism'] = 'ldap-authorization';
$config['auth_ldap_server'] = 'ldap.example.com'; // Set server(s), space separated. Prefix with ldaps:// for ssl
$config['auth_ldap_suffix'] = ',ou=People,dc=example,dc=com'; // appended to usernames
$config['auth_ldap_groupbase'] = 'ou=groups,dc=example,dc=com'; // all groups must be inside this
$config['auth_ldap_groups']['admin']['level'] = 10; // set admin group to admin level
$config['auth_ldap_groups']['pfy']['level'] = 5; // set pfy group to global read only level
$config['auth_ldap_groups']['support']['level'] = 1; // set support group as a normal user
```
#### Additional options (usually not needed)
```php
$config['auth_ldap_version'] = 3; # v2 or v3
$config['auth_ldap_port'] = 389; // 389 or 636 for ssl
$config['auth_ldap_starttls'] = True; // Enable TLS on port 389
$config['auth_ldap_prefix'] = 'uid='; // prepended to usernames
$config['auth_ldap_group'] = 'cn=groupname,ou=groups,dc=example,dc=com'; // generic group with level 0
$config['auth_ldap_groupmemberattr'] = 'memberUid'; // attribute to use to see if a user is a member of a group
$config['auth_ldap_groupmembertype'] = 'username'; // username type to find group members by, either username (default), fulldn or puredn
$config['auth_ldap_emailattr'] = 'mail'; // attribute for email address
$config['auth_ldap_attr.uid'] = 'uid'; // attribute to check username against
$config['auth_ldap_userlist_filter'] = 'service=informatique'; // Replace 'service=informatique' by your ldap filter to limit the number of responses if you have an ldap directory with thousand of users
2017-09-13 13:51:39 -05:00
$config['auth_ldap_cache_ttl'] = 300;
```
2017-11-08 09:41:38 -06:00
2022-04-22 08:28:29 +02:00
#### LDAP bind user (optional)
If your ldap server does not allow anonymous bind, it is highly
suggested to create a bind user, otherwise "remember me", alerting
users, and the API will not work.
```php
$config['auth_ldap_binduser'] = 'ldapbind'; // will use auth_ldap_prefix and auth_ldap_suffix
#$config['auth_ldap_binddn'] = 'CN=John.Smith,CN=Users,DC=MyDomain,DC=com'; // overrides binduser
$config['auth_ldap_bindpassword'] = 'password';
```
2021-07-10 03:34:01 +08:00
## View/embedded graphs without being logged into LibreNMS
2019-09-09 05:48:35 -05:00
2023-05-11 01:05:12 +01:00
!!! setting "webui/graph"
```bash
lnms config:set allow_unauth_graphs_cidr ['127.0.0.1/32']
lnms config:set allow_unauth_graphs true
2017-11-08 09:41:38 -06:00
```
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
## Single Sign-on
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
The single sign-on mechanism is used to integrate with third party
authentication providers that are managed outside of LibreNMS - such
as ADFS, Shibboleth, EZProxy, BeyondCorp, and others. A large number
of these methods use
[SAML ](https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language )
the module has been written assuming the use of SAML, and therefore
these instructions contain some SAML terminology, but it should be
possible to use any software that works in a similar way.
In order to make use of the single sign-on module, you need to have an
Identity Provider up and running, and know how to configure your
Relying Party to pass attributes to LibreNMS via header injection or
environment variables. Setting these up is outside of the scope of
this documentation.
As this module deals with authentication, it is extremely careful
about validating the configuration - if it finds that certain values
in the configuration are not set, it will reject access rather than
try and guess.
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
### Basic Configuration
2017-11-29 02:40:17 +00:00
To get up and running, all you need to do is configure the following values:
```php
$config['auth_mechanism'] = "sso";
$config['sso']['mode'] = "env";
$config['sso']['group_strategy'] = "static";
$config['sso']['static_level'] = 10;
```
This, along with the defaults, sets up a basic Single Sign-on setup that:
2019-09-09 05:48:35 -05:00
- Reads values from environment variables
- Automatically creates users when they're first seen
2020-12-30 09:38:14 -05:00
- Automatically updates users with new values
2019-09-09 05:48:35 -05:00
- Gives everyone privilege level 10
This happens to mimic the behaviour of [http-auth ](#http-auth ), so if
this is the kind of setup you want, you're probably better of just
going and using that mechanism.
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
### Security
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
If there is a proxy involved (e.g. EZProxy, Azure AD Application
Proxy, NGINX, mod_proxy) it's ___essential_ __ that you have some means
in place to prevent headers being injected between the proxy and the
end user, and also prevent end users from contacting LibreNMS
directly.
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
This should also apply to user connections to the proxy itself - the
proxy ___must not_ __ be allowed to blindly pass through HTTP
headers. ___mod_security_ __ should be considered a minimum, with a
full [WAF ](https://en.wikipedia.org/wiki/Web_application_firewall )
being strongly recommended. This advice applies to the IDP too.
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
The mechanism includes very basic protection, in the form of an IP
whitelist with should contain the source addresses of your proxies:
2017-11-29 02:40:17 +00:00
```php
$config['sso']['trusted_proxies'] = ['127.0.0.1/8', '::1/128', '192.0.2.0', '2001:DB8::'];
```
2019-09-09 05:48:35 -05:00
This configuration item should contain an array with a list of IP
addresses or CIDR prefixes that are allowed to connect to LibreNMS and
supply environment variables or headers.
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
### Advanced Configuration Options
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
#### User Attribute
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
If for some reason your relying party doesn't store the username in
2021-06-17 03:16:21 +08:00
___REMOTE\_USER___, you can override this choice.
2017-11-29 02:40:17 +00:00
```php
$config['sso']['user_attr'] = 'HTTP_UID';
```
2019-09-09 05:48:35 -05:00
Note that the user lookup is a little special - normally headers are
prefixed with ___HTTP\__ __ , however this is not the case for remote
user - it's a special case. If you're using something different you
need to figure out of the ___HTTP\__ __ prefix is required or not
yourself.
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
#### Automatic User Create/Update
2017-11-29 02:40:17 +00:00
These are enabled by default:
```php
$config['sso']['create_users'] = true;
$config['sso']['update_users'] = true;
```
2019-09-09 05:48:35 -05:00
If these are not enabled, user logins will be (somewhat silently)
rejected unless an administrator has created the account in
advance. Note that in the case of SAML federations, unless release of
the users true identity has been negotiated with the IDP, the username
(probably ePTID) is not likely to be predicable.
2017-11-29 02:40:17 +00:00
### Personalisation
2019-09-09 05:48:35 -05:00
If the attributes are being populated, you can instruct the mechanism
to add additional information to the user's database entry:
2017-11-29 02:40:17 +00:00
```php
$config['sso']['email_attr'] = "mail";
$config['sso']['realname_attr'] = "displayName";
$config['sso']['descr_attr'] = "unscoped-affiliation
```
2021-07-10 03:34:01 +08:00
#### Group Strategies
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
##### Static
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
As used above, ___static_ __ gives every single user the same privilege
level. If you're working with a small team, or don't need access
control, this is probably suitable.
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
##### Attribute
2017-11-29 02:40:17 +00:00
```php
$config['sso']['group_strategy'] = "attribute";
$config['sso']['level_attr'] = "entitlement";
```
2019-09-09 05:48:35 -05:00
If your Relying Party is capable of calculating the necessary
privilege level, you can configure the module to read the privilege
2021-06-17 03:16:21 +08:00
number straight from an attribute. ___sso\_level\_attr_ __ should contain
2019-09-09 05:48:35 -05:00
the name of the attribute that the Relying Party exposes to LibreNMS -
2021-06-17 03:16:21 +08:00
as long as ___sso\_mode_ __ is correctly set, the mechanism should find
2019-09-09 05:48:35 -05:00
the value.
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
##### Group Map
2017-11-29 02:40:17 +00:00
This is the most flexible (and complex) way of assigning privileges.
```php
$config['sso']['group_strategy'] = "map";
$config['sso']['group_attr'] = "member";
$config['sso']['group_level_map'] = ['librenms-admins' => 10, 'librenms-readers' => 1, 'librenms-billingcontacts' => 5];
$config['sso']['group_delimiter'] = ';';
```
2021-10-02 08:02:42 -05:00
This mechanism expects to find a delimited list of groups within the
2021-06-17 03:16:21 +08:00
attribute that ___sso\_group\_attr_ __ points to. This should be an
2021-10-02 08:02:42 -05:00
associative array of group name keys, with privilege levels as
2019-09-09 05:48:35 -05:00
values. The mechanism will scan the list and find the ___highest_ __
privilege level that the user is entitled to, and assign that value to
the user.
2017-11-29 02:40:17 +00:00
2021-10-02 08:02:42 -05:00
If there are no matches between the user's groups and the
___sso\_group\_level\_map___, the user will be assigned the privilege level
specified in the ___sso\_static\_level_ __ variable, with a default of 0 (no access).
This feature can be used to provide a default access level (such as read-only)
to all authenticated users.
Additionally, this format may be specific to Shibboleth; other relying party
2021-06-17 03:16:21 +08:00
software may need changes to the mechanism (e.g. ___mod\_auth\_mellon_ __
2019-09-09 05:48:35 -05:00
may create pseudo arrays).
2017-11-29 02:40:17 +00:00
There is an optional value for sites with large numbers of groups:
```php
$config['sso']['group_filter'] = "/librenms-(.*)/i";
```
This filter causes the mechanism to only consider groups matching a regular expression.
2021-07-10 03:34:01 +08:00
#### Logout Behaviour
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
LibreNMS has no capability to log out a user authenticated via Single
2020-12-30 09:38:14 -05:00
Sign-On - that responsibility falls to the Relying Party.
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
If your Relying Party has a magic URL that needs to be called to end a
session, you can configure LibreNMS to direct the user to it:
2017-11-29 02:40:17 +00:00
```php
2021-10-02 08:02:42 -05:00
# Example for Shibboleth
$config['auth_logout_handler'] = '/Shibboleth.sso/Logout';
# Example for oauth2-proxy
$config['auth_logout_handler'] = '/oauth2/sign_out';
2017-11-29 02:40:17 +00:00
```
2020-12-30 09:38:14 -05:00
This option functions independently of the Single Sign-on mechanism.
2017-11-29 02:40:17 +00:00
2021-07-10 03:34:01 +08:00
### Complete Configuration
2017-11-29 02:40:17 +00:00
2019-09-09 05:48:35 -05:00
This configuration works on my deployment with a Shibboleth relying
party, injecting environment variables, with the IDP supplying a list
of groups.
2017-11-29 02:40:17 +00:00
```php
$config['auth_mechanism'] = 'sso';
$config['auth_logout_handler'] = '/Shibboleth.sso/Logout';
$config['sso']['mode'] = 'env';
$config['sso']['create_users'] = true;
$config['sso']['update_users'] = true;
$config['sso']['realname_attr'] = 'displayName';
$config['sso']['email_attr'] = 'mail';
$config['sso']['group_strategy'] = 'map';
$config['sso']['group_attr'] = 'member';
$config['sso']['group_filter'] = '/(librenms-.*)/i';
$config['sso']['group_delimiter'] = ';';
$config['sso']['group_level_map'] = ['librenms-demo' => 11, 'librenms-globaladmin' => 10, 'librenms-globalread' => 5, 'librenms-lowpriv'=> 1];
```