Files
authentik/authentik/events/geo.py
2021-03-11 16:38:14 +01:00

22 lines
439 B
Python

"""events GeoIP Reader"""
from typing import Optional
from geoip2.database import Reader
from authentik.lib.config import CONFIG
def get_geoip_reader() -> Optional[Reader]:
"""Get GeoIP Reader, if configured, otherwise none"""
path = CONFIG.y("authentik.geoip")
if path == "" or not path:
return None
try:
return Reader(path)
except OSError:
return None
GEOIP_READER = get_geoip_reader()