mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-03-17 22:36:17 +00:00
add error handling for policy configuration issues in authentication
This commit is contained in:
@@ -23,6 +23,8 @@ async def auth_check(request: Request):
|
||||
return PlainTextResponse("Application was not found.", status_code=403)
|
||||
|
||||
effective_policy = get_effective_policy(runtime_config, context.policy_name)
|
||||
if effective_policy.mode == "error":
|
||||
return PlainTextResponse(effective_policy.error_message or "Policy configuration error.", status_code=500)
|
||||
if effective_policy.mode == "deny":
|
||||
return PlainTextResponse("Access denied by policy.", status_code=403)
|
||||
if effective_policy.mode == "bypass":
|
||||
|
||||
@@ -64,6 +64,8 @@ async def login_page(request: Request, next: str = "/"):
|
||||
context = resolve_context_from_request(request, runtime_config, next)
|
||||
effective_policy = get_effective_policy(runtime_config, context.policy_name)
|
||||
|
||||
if effective_policy.mode == "error":
|
||||
return _render(request, "error.html", status_code=500, title="Configuration error", message=effective_policy.error_message or "A policy configuration error has been detected.")
|
||||
if effective_policy.mode == "deny":
|
||||
return _render(request, "error.html", status_code=403, title="Access denied", message="This route is blocked by policy.")
|
||||
if effective_policy.mode == "bypass":
|
||||
|
||||
Reference in New Issue
Block a user