Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions apps/fdsnws/fdsnws.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@
)
from seiscomp.fdsnws.log import Log

_jwtSupported = False

try:
import jwt
from seiscomp.fdsnws.jwt import JWT

_jwtSupported = True
if int(jwt.__version__.split(".")[0]) >= 2:
_jwtSupported = True

except ImportError:
_jwtSupported = False
pass


def logSC3(entry):
Expand Down Expand Up @@ -420,7 +424,10 @@ def __init__(self, argc, argv):
self._checker = None

self._jwtEnabled = False
self._jwtIssuers = ["https://geofon.gfz.de/eas2", "https://login.earthscope.org/"]
self._jwtIssuers = [
"https://geofon.gfz.de/eas2",
"https://login.earthscope.org/",
]
self._jwtAudience = ["eas", "fdsn"]
self._jwtAlgorithms = ["RS256"]
self._jwtUpdateMin = 300
Expand Down Expand Up @@ -706,10 +713,8 @@ def initConfiguration(self):

# dataSelect filter
try:
self._dataSelectFilter = (
seiscomp.system.Environment.Instance().absolutePath(
self.configGetString("dataSelectFilter")
)
self._dataSelectFilter = seiscomp.system.Environment.Instance().absolutePath(
self.configGetString("dataSelectFilter")
)
except Exception:
pass
Expand Down Expand Up @@ -999,12 +1004,18 @@ def _site(self):
if self._jwtEnabled:
if not _jwtSupported:
seiscomp.logging.error(
"JWT is not supported due to missing dependencies"
"JWT support requires PyJWT 2.0.0 or newer. Please install PyJWT "
'with "pip" or install the required version of the python3-PyJWT '
"package if available."
)
return None

self._jwt = JWT(
self._jwtIssuers, self._jwtAudience, self._jwtAlgorithms, self._jwtUpdateMin, self._jwtUpdateMax
self._jwtIssuers,
self._jwtAudience,
self._jwtAlgorithms,
self._jwtUpdateMin,
self._jwtUpdateMax,
)

# access logger if requested
Expand All @@ -1015,9 +1026,9 @@ def _site(self):
stationInv = dataSelectInv = None
if self._serveDataSelect or self._serveStation:
retn = False
stationInv = dataSelectInv = (
seiscomp.client.Inventory.Instance().inventory()
)
stationInv = (
dataSelectInv
) = seiscomp.client.Inventory.Instance().inventory()
seiscomp.logging.info("inventory loaded")

if self._serveDataSelect and self._serveStation:
Expand Down