Exemplo n.º 1
0
 def setUp(self):
     self.private_key = open("jwkaas/test/test-key").read()
     self.my_jwkaas = JWKaas(
         "expected_audience",
         "expected_issuer",
         jwks_file="jwkaas/test/test-jwks.json",
     )
import config
from flask import g, request
from jwkaas import JWKaas
from requests.exceptions import ConnectionError

from utils import get_secret

my_jwkaas = None
api_key_secret = None
api_key_secret_conversion = None

if hasattr(config, "OAUTH_JWKS_URL"):
    my_jwkaas = JWKaas(
        config.OAUTH_EXPECTED_AUDIENCE,
        config.OAUTH_EXPECTED_ISSUER,
        jwks_url=config.OAUTH_JWKS_URL,
    )

if hasattr(config, "API_KEY_SECRET"):
    api_key_secret = get_secret(os.environ["PROJECT_ID"],
                                config.API_KEY_SECRET)

if hasattr(config, "API_KEY_SECRET_CONVERSION"):
    api_key_secret_conversion = config.API_KEY_SECRET_CONVERSION


class LevelRaiser(logging.Filter):
    def filter(self, record):
        if record.levelno == logging.WARNING:
            record.levelno = logging.INFO
Exemplo n.º 3
0
import config
import logging
from jwkaas import JWKaas

from flask import g

my_jwkaas = None
my_e2e_jwkaas = None
my_b2b_jwkaas = None

if hasattr(config, 'OAUTH_JWKS_URL'):
    my_jwkaas = JWKaas(config.OAUTH_EXPECTED_AUDIENCE,
                       config.OAUTH_EXPECTED_ISSUER,
                       jwks_url=config.OAUTH_JWKS_URL)

if hasattr(config, 'OAUTH_B2B_JWKS_URL'):
    my_b2b_jwkaas = JWKaas(config.OAUTH_B2B_EXPECTED_AUDIENCE,
                           config.OAUTH_B2B_EXPECTED_ISSUER,
                           jwks_url=config.OAUTH_B2B_JWKS_URL)

if hasattr(config, 'OAUTH_E2E_JWKS_URL'):
    my_e2e_jwkaas = JWKaas(config.OAUTH_E2E_EXPECTED_AUDIENCE,
                           config.OAUTH_E2E_EXPECTED_ISSUER,
                           jwks_url=config.OAUTH_E2E_JWKS_URL)


def refine_token_info(token_info):
    if token_info and 'scopes' in token_info:
        if 'snbplanningapi.editor' in token_info['scopes']:
            token_info['scopes'].append('snbplanningapi.planner')
    return token_info