Security: add @auth_req to unprotected endpoints, lower admin rate limits
This commit is contained in:
1 parent
fc43648089
commit
7bfcafdaf6
1 file changed
+18
-5
+18
-5
@@ -36,7 +36,7 @@ def register_api_routes(app, services, settings):
|
||||
# Server actions
|
||||
@app.route('/server/action', methods=['POST'])
|
||||
@auth_req
|
||||
@limiter.limit("20 per hour")
|
||||
@limiter.limit("10 per hour")
|
||||
def server_action():
|
||||
deployment = request.form.get('deployment', '')
|
||||
action = request.form.get('action', '')
|
||||
@@ -259,7 +259,7 @@ def register_api_routes(app, services, settings):
|
||||
|
||||
# Ban management
|
||||
@app.route('/api/ban_player', methods=['POST'])
|
||||
@limiter.limit("20 per hour")
|
||||
@limiter.limit("5 per hour")
|
||||
def api_ban_player():
|
||||
try:
|
||||
player_id = request.form.get('player_id', type=int)
|
||||
@@ -319,7 +319,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': False, 'error': str(e)})
|
||||
|
||||
@app.route('/api/unban_player', methods=['POST'])
|
||||
@limiter.limit("20 per hour")
|
||||
@limiter.limit("5 per hour")
|
||||
def api_unban_player():
|
||||
try:
|
||||
player_id = request.form.get('player_id', type=int)
|
||||
@@ -343,7 +343,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': False, 'error': str(e)})
|
||||
|
||||
@app.route('/api/kick_player', methods=['POST'])
|
||||
@limiter.limit("30 per hour")
|
||||
@limiter.limit("10 per hour")
|
||||
def api_kick_player():
|
||||
try:
|
||||
player_id = request.form.get('player_id', type=int)
|
||||
@@ -357,7 +357,7 @@ def register_api_routes(app, services, settings):
|
||||
|
||||
# Vitals editing
|
||||
@app.route('/api/edit_vitals', methods=['POST'])
|
||||
@limiter.limit("30 per hour")
|
||||
@limiter.limit("10 per hour")
|
||||
def api_edit_vitals():
|
||||
try:
|
||||
pawn_id = request.form.get('pawn_id', type=int)
|
||||
@@ -766,6 +766,7 @@ def register_api_routes(app, services, settings):
|
||||
return k8s.ssh.run(full_cmd, timeout=timeout)
|
||||
|
||||
@app.route('/api/files/list', methods=['POST'])
|
||||
@auth_req
|
||||
def api_files_list():
|
||||
path = request.form.get('path', '/srv')
|
||||
if not _validate_fb_path(path):
|
||||
@@ -794,6 +795,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': True, 'files': files})
|
||||
|
||||
@app.route('/api/files/view')
|
||||
@auth_req
|
||||
def api_files_view():
|
||||
path = request.args.get('path', '')
|
||||
if not path:
|
||||
@@ -806,6 +808,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': True, 'content': out, 'path': path})
|
||||
|
||||
@app.route('/api/files/save', methods=['POST'])
|
||||
@auth_req
|
||||
@limiter.limit("50 per hour")
|
||||
def api_files_save():
|
||||
path = request.form.get('path', '')
|
||||
@@ -888,6 +891,7 @@ def register_api_routes(app, services, settings):
|
||||
|
||||
# Director API proxy
|
||||
@app.route('/api/director/battlegroup')
|
||||
@auth_req
|
||||
def director_battlegroup():
|
||||
try:
|
||||
logger.info(f"Director request: {director_base}/v0/battlegroup")
|
||||
@@ -898,6 +902,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
@app.route('/api/director/update_config', methods=['POST'])
|
||||
@auth_req
|
||||
def director_update_config():
|
||||
try:
|
||||
config = request.get_json()
|
||||
@@ -942,6 +947,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
@app.route('/api/director/clear_config', methods=['POST'])
|
||||
@auth_req
|
||||
def director_clear_config():
|
||||
try:
|
||||
map_name = request.get_data(as_text=True).strip()
|
||||
@@ -953,6 +959,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
@app.route('/api/director/character_transfer', methods=['GET'])
|
||||
@auth_req
|
||||
def director_character_transfer_get():
|
||||
try:
|
||||
data = _director_request('/v0/BattlegroupFetchCharacterTransferRules')
|
||||
@@ -961,6 +968,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
@app.route('/api/director/character_transfer', methods=['POST'])
|
||||
@auth_req
|
||||
def director_character_transfer_update():
|
||||
try:
|
||||
config = request.get_json()
|
||||
@@ -979,6 +987,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
@app.route('/api/director/character_transfer_clear', methods=['POST'])
|
||||
@auth_req
|
||||
def director_character_transfer_clear():
|
||||
try:
|
||||
result = _director_request('/v0/BattlegroupClearCharacterTransferOverrides', method='POST', timeout=30)
|
||||
@@ -991,6 +1000,7 @@ def register_api_routes(app, services, settings):
|
||||
|
||||
# Update management
|
||||
@app.route('/api/update/status')
|
||||
@auth_req
|
||||
def api_update_status():
|
||||
updater = services.get('updater')
|
||||
if not updater:
|
||||
@@ -1001,6 +1011,7 @@ def register_api_routes(app, services, settings):
|
||||
})
|
||||
|
||||
@app.route('/api/update/apply', methods=['POST'])
|
||||
@auth_req
|
||||
def api_update_apply():
|
||||
updater = services.get('updater')
|
||||
if not updater:
|
||||
@@ -1009,6 +1020,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': success, 'message': message})
|
||||
|
||||
@app.route('/api/update/test', methods=['POST'])
|
||||
@auth_req
|
||||
def api_update_test():
|
||||
"""Force show update banner for testing."""
|
||||
updater = services.get('updater')
|
||||
@@ -1018,6 +1030,7 @@ def register_api_routes(app, services, settings):
|
||||
return jsonify({'success': False, 'error': 'Updater not available'})
|
||||
|
||||
@app.route('/api/update/check', methods=['POST'])
|
||||
@auth_req
|
||||
def api_update_check():
|
||||
"""Force a fresh check against GitHub."""
|
||||
updater = services.get('updater')
|
||||
|
||||
Reference in new issue
Block a user