def __init__(self): self.latestToken = "" self.s = requests.Session() if getEnvVar('TOKEN', False): self.securityToken = SecurityToken(logger, DEBUG) else: self.securityToken = None if getEnvVar('MTLS', False): serviceCert = ServiceCert(logger, serviceType, DEBUG) self.serviceCertFileName = serviceCert.getServiceCertFileName() self.serviceKeyFileName = serviceCert.getServiceKeyFileName() self.caCertFileName = serviceCert.getCaCertFileName() self.s.cert = (self.serviceCertFileName, self.serviceKeyFileName) self.s.verify = self.caCertFileName
import json import falcon from general import getEnvVar from MiSSFire import CorrelationToken TOKEN = getEnvVar('TOKEN', False) if TOKEN: correlationToken = CorrelationToken(logger, DEBUG) class AuthMiddleware(object): def process_request(self, req, resp): token = req.get_header('authJWT') challenges = ['Token type="JWT"'] if token is None: description = ('Please provide an auth token ' 'as part of the request.') raise falcon.HTTPUnauthorized('Auth token required', description, challenges, href='http://docs.example.com/auth') if not correlationToken.validate(token): description = ('The provided auth token is not valid. ' 'Please request a new token and try again.')
from flask import Flask, request, abort from requests import codes from requests.exceptions import ConnectionError from werkzeug.exceptions import NotFound, ServiceUnavailable from general import log, getEnvVar, isDocker, niceJson, allLinks # Use the name of the current directory as a service type serviceType = os.path.basename(os.getcwd()) logger = log(serviceType).logger # Setup MiSSFire try: PROT = 'http' if getEnvVar('MTLS', False) or getEnvVar('TOKEN', False): from MiSSFire import Requests requests = Requests() if getEnvVar('MTLS', False): PROT = 'https' if getEnvVar('TOKEN', False): from MiSSFire import jwt_conditional else: def jwt_conditional(reqs): def real_decorator(f): return f return real_decorator else:
import time from functools import wraps from socket import error as socket_error import jwt import requests from flask import request, abort from cryptography.x509 import load_pem_x509_certificate from cryptography.hazmat.backends import default_backend from general import log, getEnvVar, isDocker serviceType = os.path.basename(os.getcwd()) logger = log(serviceType).logger DEBUG = getEnvVar('SERVICE_DEBUG', False) if isDocker(): CA_HOSTNAME = "ca" CA_PORT = 80 TOKEN_HOSTNAME = "reversests" TOKEN_PORT = 80 else: CA_HOSTNAME = '0.0.0.0' CA_PORT = 8080 TOKEN_HOSTNAME = '0.0.0.0' TOKEN_PORT = 8083 CA_URL = 'https://%s:%s/' % (CA_HOSTNAME, CA_PORT) TOKEN_URL = 'http://%s:%s/' % (TOKEN_HOSTNAME, TOKEN_PORT)
import os import sys import datetime from flask import Flask, request, abort from general import log, getEnvVar, isDocker, niceJson, allLinks from db_controller import db_create, db_migrate, dbCtrl # Use the name of the current directory as a service type serviceType = os.path.basename(os.getcwd()) logger = log(serviceType).logger # Setup MiSSFire if getEnvVar('TOKEN', False): try: from MiSSFire import jwt_conditional, Requests requests = Requests() except ImportError: logger.error("Module MiSSFire is required. Terminating.") exit() else: from general import Requests requests = Requests() def jwt_conditional(reqs): def real_decorator(f): return f return real_decorator
import os import sys from flask import Flask, request, abort from general import log, getEnvVar, isDocker, niceJson, allLinks from db_controller import db_create, db_migrate, dbCtrl # Use the name of the current directory as a service type serviceType = os.path.basename(os.getcwd()) logger = log(serviceType).logger # Setup MiSSFire TOKEN_REQUIRED = getEnvVar('TOKEN', False) try: if TOKEN_REQUIRED: from MiSSFire import jwt_conditional, Requests requests = Requests() else: from general import Requests requests = Requests() def jwt_conditional(reqs): def real_decorator(f): return f return real_decorator except ImportError: logger.error("Module MiSSFire is required. Terminating.") exit()
import json import falcon from requests import codes from requests.exceptions import ConnectionError from general import log, getEnvVar, isDocker from falcon_app_template import app SERVICE_TYPE = "apigateway" logger = log(SERVICE_TYPE).logger if getEnvVar('MTLS', False): PROT = 'https' from muServSec import ServiceCert, Requests serviceCert = ServiceCert(logger, SERVICE_TYPE, True) requests = Requests(serviceCert) else: PROT = 'http' import requests if isDocker(): USERS_SERVICE_URL = '%s://%s:%s/' % (PROT, "users", 80) ACCOUNTS_SERVICE_URL = '%s://%s:%s/' % (PROT, "accounts", 80) TRANSACTIONS_SERVICE_URL = '%s://%s:%s/' % (PROT, "transactions", 80) PAYMENT_SERVICE_URL = '%s://%s:%s/' % (PROT, "payment", 80) else: USERS_SERVICE_URL = '%s://%s:%s/' % (PROT, '0.0.0.0', 9081) ACCOUNTS_SERVICE_URL = '%s://%s:%s/' % (PROT, '0.0.0.0', 9082) TRANSACTIONS_SERVICE_URL = '%s://%s:%s/' % (PROT, '0.0.0.0', 9083)