文件预览优化
This commit is contained in:
1 parent
f91d44ca24
commit
7f66d6f20c
5 files changed
+504
-165
No files matched your search
@@ -19,11 +19,25 @@ integration_bp = Blueprint('integration', __name__)
|
||||
def _require_integration_key():
|
||||
configured = str(current_app.config.get('INTEGRATION_API_KEY') or '').strip()
|
||||
incoming = str(request.headers.get('X-Integration-Key') or '').strip()
|
||||
|
||||
if not configured:
|
||||
return jsonify({'error': 'INTEGRATION_API_KEY is not configured'}), 503
|
||||
if configured != incoming:
|
||||
return jsonify({'error': 'Unauthorized'}), 401
|
||||
return None
|
||||
|
||||
if configured == incoming:
|
||||
return None
|
||||
|
||||
token = request.args.get('token')
|
||||
if token:
|
||||
try:
|
||||
import jwt
|
||||
secret = configured or str(current_app.config.get('SECRET_KEY') or 'default-secret').strip()
|
||||
jwt.decode(token, secret, algorithms=['HS256'])
|
||||
return None
|
||||
except Exception as e:
|
||||
current_app.logger.warning(f"Integration API token validation failed: {e}")
|
||||
pass
|
||||
|
||||
return jsonify({'error': 'Unauthorized'}), 401
|
||||
|
||||
|
||||
def _integration_base_url() -> str:
|
||||
|
||||
Reference in new issue
Block a user