From b4b81f09213fad47f6378c3028aff5e379a8c233 Mon Sep 17 00:00:00 2001 From: fengfei Date: Sun, 3 Sep 2017 12:04:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/config/web/routes/RouteConfig.java | 11 +- .../webpages/lanproxy-config/index.html | 169 +++++++++--------- 2 files changed, 93 insertions(+), 87 deletions(-) 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 @@ +