"""Daemon Handler. This will check if the service is in JWT Enable list or not. and accordingly returns authorization""" from daemonJwtHandler import config from daemonJwtHandler.constants import auth from daemonJwtHandler.logic.jwt_services import JwtServices def daemon_handler(service_name): """This will check if the service is in JWT Enable list or not. and accordingly returns authorization Keyword arguments: argument -- service name which daemon is calling Return: JWT token or None """ if config.ENVIRONMENT != config.ENVIRONMENT_DEV: jwtInstance = JwtServices.getInstance() jwtServicesCacheList = jwtInstance.getCache( auth.JWT_ENABLED_SERVICES_SECRET_KEY) jwt_token = jwtInstance.getCache(auth.JWT_SECRET_KEY) if jwtServicesCacheList and (service_name in jwtServicesCacheList): authorization = auth.AUTHORIZATION_FORMAT.format( jwt_token=jwt_token) else: authorization = None return authorization