summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2019-10-01 13:27:41 +0000
committerJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2019-10-01 15:12:16 +0000
commit95c9ad4dc176860c85a07d0db4cb4179929bdb54 (patch)
treee3a99c9e6392d957946a0e3ce0837c402cf9e6c4
parent9519d67c7a9a0e97a75115f9ff99d4fb0bb81b21 (diff)
downloadgeoclue-95c9ad4dc176860c85a07d0db4cb4179929bdb54.tar.gz
config: Make the Mozilla API key configurable
And do not expose it in the configuration file.
-rw-r--r--data/geoclue.conf.in18
-rw-r--r--meson.build1
-rw-r--r--meson_options.txt3
-rw-r--r--src/gclue-config.c4
4 files changed, 16 insertions, 10 deletions
diff --git a/data/geoclue.conf.in b/data/geoclue.conf.in
index fb111de..bebe471 100644
--- a/data/geoclue.conf.in
+++ b/data/geoclue.conf.in
@@ -42,13 +42,13 @@ enable=true
# Enable WiFi source
enable=true
-# URL to the wifi geolocation service. The key can currenty be anything, just
-# needs to be present but that is likely going to change in future.
-url=https://location.services.mozilla.com/v1/geolocate?key=geoclue
+# URL to the WiFi geolocation service. If not set, defaults to Mozilla's
+# Location Service with a hardcoded key. To use a custom key, uncomment this URL
+# while changing YOUR_KEY to your MLS API key.
+#url=https://location.services.mozilla.com/v1/geolocate?key=YOUR_KEY
-# To use the Google geolocation service instead of mozilla's, simply uncomment
-# this url while changing API_KEY to your Google API key and comment out or
-# remove the url above.
+# To use the Google geolocation service instead of Mozilla's, uncomment this URL
+# while changing YOUR_KEY to your Google API key.
#
# WARNING: Please make sure that you are complying with the Google's ToS and
# policies if you uncomment this:
@@ -63,8 +63,10 @@ url=https://location.services.mozilla.com/v1/geolocate?key=geoclue
#
submit-data=false
-# URL to submission API of Mozilla Location Service
-submission-url=https://location.services.mozilla.com/v1/submit?key=geoclue
+# URL to submission API of Mozilla Location Service. If not set, defaults to
+# Mozilla's API with a hardcoded key. To use a custom key, uncomment this URL
+# while changing YOUR_KEY to your MLS API key.
+#submission-url=https://location.services.mozilla.com/v1/submit?key=YOUR_KEY
# A nickname to submit network data with. A nickname must be 2-32 characters long.
submission-nick=geoclue
diff --git a/meson.build b/meson.build
index fde6fa3..7547887 100644
--- a/meson.build
+++ b/meson.build
@@ -30,6 +30,7 @@ conf.set_quoted('PACKAGE_BUGREPORT', 'https://gitlab.freedesktop.org/geoclue/geo
conf.set_quoted('TEST_SRCDIR', meson.source_root() + '/data/')
conf.set_quoted('LOCALEDIR', localedir)
conf.set_quoted('SYSCONFDIR', sysconfdir)
+conf.set_quoted('MOZILLA_API_KEY', get_option('mozilla-api-key'))
conf.set10('GCLUE_USE_3G_SOURCE', get_option('3g-source'))
conf.set10('GCLUE_USE_CDMA_SOURCE', get_option('cdma-source'))
conf.set10('GCLUE_USE_MODEM_GPS_SOURCE', get_option('modem-gps-source'))
diff --git a/meson_options.txt b/meson_options.txt
index 83bc60e..f5d42e3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -34,3 +34,6 @@ option('systemd-system-unit-dir',
option('dbus-srv-user',
type: 'string', value: 'root',
description: 'The user (existing) as which the service will run')
+option('mozilla-api-key',
+ type: 'string', value: 'geoclue',
+ description: 'Your API key for Mozilla Location Service')
diff --git a/src/gclue-config.c b/src/gclue-config.c
index d259c71..df4adcc 100644
--- a/src/gclue-config.c
+++ b/src/gclue-config.c
@@ -216,8 +216,8 @@ load_enable_source_config (GClueConfig *config,
return enable;
}
-#define DEFAULT_WIFI_URL "https://location.services.mozilla.com/v1/geolocate?key=geoclue"
-#define DEFAULT_WIFI_SUBMIT_URL "https://location.services.mozilla.com/v1/submit?key=geoclue"
+#define DEFAULT_WIFI_URL "https://location.services.mozilla.com/v1/geolocate?key=" MOZILLA_API_KEY
+#define DEFAULT_WIFI_SUBMIT_URL "https://location.services.mozilla.com/v1/submit?key=" MOZILLA_API_KEY
static void
load_wifi_config (GClueConfig *config)