diff --git a/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/web/routes/RouteConfig.java b/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/web/routes/RouteConfig.java index 2877726..a90cfb6 100644 --- a/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/web/routes/RouteConfig.java +++ b/proxy-server/src/main/java/org/fengfei/lanproxy/server/config/web/routes/RouteConfig.java @@ -56,6 +56,14 @@ public class RouteConfig { } } + String auth = request.headers().get(HttpHeaders.Names.AUTHORIZATION); + if (!authenticated && auth != null) { + String[] authArr = auth.split(" "); + if (authArr.length == 2 && authArr[0].equals(ProxyConfig.getInstance().getConfigAdminUsername()) && authArr[1].equals(ProxyConfig.getInstance().getConfigAdminPassword())) { + authenticated = true; + } + } + if (!request.getUri().equals("/login") && !authenticated) { throw new ContextException(ResponseInfo.CODE_UNAUTHORIZED); } @@ -118,8 +126,7 @@ public class RouteConfig { return ResponseInfo.build(ResponseInfo.CODE_INVILID_PARAMS, "Error username or password"); } - if (username.equals(ProxyConfig.getInstance().getConfigAdminUsername()) - && password.equals(ProxyConfig.getInstance().getConfigAdminPassword())) { + if (username.equals(ProxyConfig.getInstance().getConfigAdminUsername()) && password.equals(ProxyConfig.getInstance().getConfigAdminPassword())) { token = UUID.randomUUID().toString().replace("-", ""); return ResponseInfo.build(token); } diff --git a/proxy-server/webpages/lanproxy-config/index.html b/proxy-server/webpages/lanproxy-config/index.html index c76ff93..0fc0989 100644 --- a/proxy-server/webpages/lanproxy-config/index.html +++ b/proxy-server/webpages/lanproxy-config/index.html @@ -17,14 +17,13 @@
-
- -
+
@@ -38,96 +37,96 @@ +