INNER CODE UNIT · Python

get_request_token

sky22333/ansible-ui · app.py:69

def get_request_token():
    """从请求中提取JWT令牌"""
    auth_header = request.headers.get('Authorization', '')
    if auth_header.startswith('Bearer '):
        return auth_header.split(' ', 1)[1]

    return request.cookies.get('token') or request.args.get('token')

def ensure_crypto_key():
    """确保运行期加密密钥已初始化"""
    from crypto_utils import CRYPTO_KEY

    if isinstance(CRYPTO_KEY, bytes) and len(CRYPTO_KEY) == 32:
        return True

    if not ADMIN_USERNAME or not ADMIN_PASSWORD:
        app.logger.error("缺少管理员凭证,无法派生加密密钥")
        return False

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…