Files
authentik/authentik/events/geo.py
2021-02-12 09:52:14 +01:00

19 lines
374 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 == "":
return None
return Reader(path)
GEOIP_READER = get_geoip_reader()