dodatkowe poprawki i funkcje
This commit is contained in:
6
app.py
6
app.py
@@ -143,7 +143,7 @@ else:
|
||||
API_TOKEN = "superSecretTokenABC123"
|
||||
logger.info("API_TOKEN ustawiony na wartość domyślną: superSecretTokenABC123")
|
||||
|
||||
def require_auth():
|
||||
def requireAuth():
|
||||
"""Wymusza autoryzację przy pomocy nagłówka Authorization,
|
||||
który powinien zawierać API_TOKEN."""
|
||||
token = request.headers.get("Authorization")
|
||||
@@ -152,7 +152,7 @@ def require_auth():
|
||||
logger.warning("Nieprawidłowy token w nagłówku Authorization. Oczekiwano innego ciągu znaków.")
|
||||
abort(401, description="Unauthorized")
|
||||
|
||||
def validate_hosts_syntax(hosts_content):
|
||||
def validateHostsSyntax(hosts_content):
|
||||
import ipaddress
|
||||
seen = {}
|
||||
lines = hosts_content.splitlines()
|
||||
@@ -252,7 +252,7 @@ def root_index():
|
||||
|
||||
@app.route('/hosts', methods=['GET'])
|
||||
def get_hosts():
|
||||
require_auth()
|
||||
requireAuth()
|
||||
metrics["hosts_get"] += 1
|
||||
try:
|
||||
with open('/etc/hosts', 'r') as f:
|
||||
|
Reference in New Issue
Block a user