Debian Codegraph @

doc/sources/admin/locationdetect.rst

raw
1 Location detection plugin
2 =========================
3
4 This plugin use GeoIP database and browser detection module to get city, country, browser and OS from connected user.
5
6 Required dependencies
7 ---------------------
8
9 You need to install the following Perl modules: ``HTTP::BrowserDetect``, ``MaxMind::DB::Reader``.
10
11 GeoIP database
12 --------------
13
14 You can use either:
15
16 * Any **DB-IP** databases
17 * **MaxMind GeoLite2** databases (free account required)
18
19 Using DB-IP (recommended for simplicity, no account required)
20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
22 Download the free City database from `<https://db-ip.com/db/download/ip-to-city-lite>`__:
23
24 .. code-block:: shell
25
26 YEAR_MONTH=$(date +%Y-%m)
27 wget "https://download.db-ip.com/free/dbip-city-lite-${YEAR_MONTH}.mmdb.gz"
28 gunzip dbip-city-lite-${YEAR_MONTH}.mmdb.gz
29 mv dbip-city-lite-${YEAR_MONTH}.mmdb /var/lib/GeoIP/dbip-city-lite.mmdb
30
31 Using MaxMind GeoLite2
32 ~~~~~~~~~~~~~~~~~~~~~~
33
34 Create an account on `<https://www.maxmind.com/en/home>`__ and put credentials in ``/etc/GeoIP.conf``:
35
36 .. code-block:: shell
37
38 # Enter your account ID and license key below. These are available from
39 # https://www.maxmind.com/en/my_license_key. If you are only using free
40 # GeoLite databases, do not uncomment these lines.
41 AccountID 111111
42 LicenseKey xxxxxx
43
44 Update database:
45
46 .. code-block:: shell
47
48 geoipupdate -v
49
50 The database files should be present in ``/var/lib/GeoIP2/``.
51
52 Configuration
53 -------------
54
55 In section "General Parameters > Plugins > Location detection", you can set these parameters.
56
57 - **Parameters**:
58
59 - **Enable plugin**: Enable/disable this plugin
60 - **Path to GeoIP database**: Full path to GeoIP2 database
61 - **Information requested for IP**: Choose ``city`` or ``country``
62 - **Information requested for User Agent**: Choose ``browser`` or ``os``
63
64 Usage
65 -----
66
67 When plugin is enabled, new informations will be stored in session:
68
69 * ``_location_detect_env_ua``: User Agent information
70 * ``_location_detect_env_ip``: GeoIP information
71 * ``_location_detect_env_display``: Both User Agent and GeoIP information
72
73 To see them in :doc:`login history<loginhistory>`, you can add them to the list of session data to store.
74
75 You can also use these information in 2FA rules, access rules, adaptive authentication rules...
76
77 For example, to use these information in the :doc:`new location warning plugin<newlocationwarning>`, use ``_location_detect_env`` for ``newLocationWarningLocationAttribute`` and ``_location_detect_env_display`` for ``newLocationWarningLocationDisplayAttribute``.