<commit_before>import asyncio
import logging

from jose import jwt, JWTError

from repour.config import config

logger = logging.getLogger(__name__)


@asyncio.coroutine
def verify_token(token):
    c = yield from config.get_configuration()
    logger.info('Got token: ' + str(token))

    OPTIONS = {
        'verify_signature': True,
        'verify_aud': False,
        'verify_iat': True,
        'verify_exp': True,
        'verify_nbf': True,
        'verify_iss': True,
        'verify_sub': False,
        'verify_jti': True,
        'verify_at_hash': True,
        'leeway': 0,
    }

    try:
        token = jwt.decode(token, c['auth']['oauth2_jwt']['public_key'], algorithms=['RS256'], options=OPTIONS,
                           issuer=c['auth']['oauth2_jwt']['token_issuer'])
        logger.info('Got valid token: ' + str(token))
        return True
    except JWTError as e:<commit_msg>[NCL-3741] Remove user token from logs<commit_after>import asyncio
import logging

from jose import jwt, JWTError

from repour.config import config

logger = logging.getLogger(__name__)


@asyncio.coroutine
def verify_token(token):
    c = yield from config.get_configuration()
    logger.info('Got token!')

    OPTIONS = {
        'verify_signature': True,
        'verify_aud': False,
        'verify_iat': True,
        'verify_exp': True,
        'verify_nbf': True,
        'verify_iss': True,
        'verify_sub': False,
        'verify_jti': True,
        'verify_at_hash': True,
        'leeway': 0,
    }

    try:
        token = jwt.decode(token, c['auth']['oauth2_jwt']['public_key'], algorithms=['RS256'], options=OPTIONS,
                           issuer=c['auth']['oauth2_jwt']['token_issuer'])
        logger.info('Got valid token!')
        return True
    except JWTError as e:
{'fraction_non_alphanumeric': 0.13173985547526404, 'fraction_numerical': 0.008893829905503057, 'mean_word_length': 2.7267080745341614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7359251', 'n_tokens_mistral': 590, 'n_tokens_neox': 588, 'n_words': 128}