Exemplo n.º 1
0
    app,
    allow_headers=(
        "x-requested-with",
        "content-type",
        "accept",
        "origin",
        "authorization",
        "x-csrftoken",
        "withcredentials",
        "cache-control",
        "cookie",
        "session-id",
    ),
    supports_credentials=True,
)
config = get_config()
logger = getLogger(__name__)

cis_environment = config("environment", namespace="cis")
# Configure the X-Ray recorder to generate segments with our service name
xray_recorder.configure(
    service="{}_profile_retrieval_serivce".format(cis_environment))

# Instrument the Flask application
XRayMiddleware(app, xray_recorder)

if config("initialize_vault", namespace="person_api",
          default="false") == "true":
    logger.debug(
        "Initializing vault and pre-seeding it, this will take some time...")
    initialize_vault()
Exemplo n.º 2
0
Arquivo: idp.py Projeto: romanom/cis
import json
import logging

from functools import wraps
from flask import request
from flask import _request_ctx_stack
from six.moves.urllib.request import urlopen
from jose import jwt

from cis_profile_retrieval_service.common import get_config
from cis_profile_retrieval_service.exceptions import AuthError

logger = logging.getLogger(__name__)

CONFIG = get_config()

AUTH0_DOMAIN = CONFIG("auth0_domain", namespace="person_api", default="auth-dev.mozilla.auth0.com")
API_IDENTIFIER = CONFIG("api_identifier", namespace="person_api", default="api.dev.sso.allizom.org")
ALGORITHMS = CONFIG("algorithms", namespace="change_service", default="RS256")


# Format error response and append status code
def get_token_auth_header():
    """Obtains the Access Token from the Authorization Header"""
    auth = request.headers.get("Authorization", None)
    if not auth:
        raise AuthError(
            {"code": "authorization_header_missing", "description": "Authorization header is expected"}, 401
        )

    parts = auth.split()