INNER CODE UNIT · Python
sftp_client_for_host
sky22333/ansible-ui · app.py:120
def sftp_client_for_host(host, timeout=10):
"""为指定主机创建并管理SFTP连接"""
with ssh_client_for_host(host, timeout=timeout) as ssh:
with ssh.open_sftp() as sftp:
yield sftp
def auth_required(f):
"""JWT认证要求装饰器"""
@wraps(f)
def decorated_function(*args, **kwargs):
token = get_request_token()
if not token:
return jsonify({'error': 'Unauthorized'}), 401
user = decode_token(token)
if not user:
return jsonify({'error': 'Invalid or expired token'}), 401