Archived
1.0.4 - ograniczenia IP i edycja przekierowań
Wydanie WGTools-Extended / release (push) Successful in 15s
Wydanie WGTools-Extended / release (push) Successful in 15s
This commit is contained in:
1 parent
3841e93e32
commit
6e7eaa9282
13 files changed
+115
-17
No files matched your search
+17
-1
@@ -476,6 +476,12 @@ class ExtendedForwardRequest(BaseModel):
|
||||
target_ip: str = Field(max_length=15)
|
||||
target_port: int = Field(ge=1, le=65535)
|
||||
protocol: str = Field(max_length=4)
|
||||
restrict_sources: bool = False
|
||||
allowed_sources: list[str] = Field(default_factory=list, max_length=32)
|
||||
|
||||
|
||||
class ExtendedForwardUpdateRequest(ExtendedForwardRequest):
|
||||
id: str = Field(pattern=r"^[0-9a-f]{16}$")
|
||||
|
||||
|
||||
class ExtendedForwardDeleteRequest(BaseModel):
|
||||
@@ -685,7 +691,7 @@ async def require_authentication(request: Request, call_next):
|
||||
access = get_user_access(int(current["id"]), initialize=False)
|
||||
request.state.access = access
|
||||
if access["role"] != "admin":
|
||||
allowed = {"/", "/clients", "/api/interfaces", "/api/snapshot", "/api/metrics/history", "/api/app-settings", "/api/auth/logout", "/api/clients/create", "/api/clients/update", "/api/clients/credentials/rotate", "/api/clients/config", "/api/clients/config/download", "/api/clients/qr", "/api/extended/forwardings", "/api/extended/forwardings/delete"}
|
||||
allowed = {"/", "/clients", "/api/interfaces", "/api/snapshot", "/api/metrics/history", "/api/app-settings", "/api/auth/logout", "/api/clients/create", "/api/clients/update", "/api/clients/credentials/rotate", "/api/clients/config", "/api/clients/config/download", "/api/clients/qr", "/api/extended/forwardings", "/api/extended/forwardings/update", "/api/extended/forwardings/delete"}
|
||||
if path not in allowed or (path == "/api/app-settings" and request.method != "GET"):
|
||||
return JSONResponse(status_code=403, content={"ok": False, "error": "Brak uprawnień"})
|
||||
if path.startswith("/api/clients/") or path.startswith("/api/extended/forwardings") or path == "/api/snapshot":
|
||||
@@ -1769,6 +1775,16 @@ def api_extended_forward_add(payload: ExtendedForwardRequest, request: Request):
|
||||
return JSONResponse(status_code=400, content={"ok": False, "error": str(exc)})
|
||||
|
||||
|
||||
@app.post("/api/extended/forwardings/update")
|
||||
def api_extended_forward_update(payload: ExtendedForwardUpdateRequest, request: Request):
|
||||
try:
|
||||
result = run_helper("extended_forward_update", payload.model_dump(), interface=request_interface(request))
|
||||
audit_action(request, "network.forward_updated", object=request_interface(request), result="saved", details=payload.model_dump())
|
||||
return result
|
||||
except HelperError as exc:
|
||||
return JSONResponse(status_code=400, content={"ok": False, "error": str(exc)})
|
||||
|
||||
|
||||
@app.post("/api/extended/forwardings/delete")
|
||||
def api_extended_forward_delete(payload: ExtendedForwardDeleteRequest, request: Request):
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user