-
Notifications
You must be signed in to change notification settings - Fork 0
chore: enhance AuthGuardFilter and JSP files for improved static asse… #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,6 @@ | |||||
| import javax.servlet.http.HttpFilter; | ||||||
| import javax.servlet.http.HttpServletRequest; | ||||||
| import javax.servlet.http.HttpServletResponse; | ||||||
| import javax.servlet.http.HttpSession; | ||||||
| import java.io.IOException; | ||||||
| import java.util.Set; | ||||||
|
|
||||||
|
|
@@ -37,11 +36,40 @@ protected void doFilter(HttpServletRequest req, HttpServletResponse resp, Filter | |||||
| throws IOException, ServletException { | ||||||
|
|
||||||
| String contextPath = req.getContextPath(); | ||||||
| String path = req.getRequestURI().substring(contextPath.length()); | ||||||
| String uri = req.getRequestURI(); | ||||||
| String path = uri.substring(contextPath.length()); | ||||||
| String method = req.getMethod(); | ||||||
|
|
||||||
| boolean needsAuth = false; | ||||||
|
|
||||||
| // 1) Always allow static assets | ||||||
| if (path.startsWith("/css/") | ||||||
| || path.startsWith("/images/") | ||||||
| || path.startsWith("/apidocs/") | ||||||
| || path.equals("/favicon.ico") | ||||||
| || path.startsWith("/favicon") | ||||||
|
||||||
| || path.startsWith("/favicon") |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The static asset filtering has redundant checks. Lines 46-50 check for paths starting with "/css/", "/images/", etc., while lines 51-58 check for file extensions like ".css", ".js", ".png", etc. A file like "/css/styles.css" would be allowed by line 46 before reaching the extension check on line 51. Similarly, a CSS file served from a non-standard location (e.g., "/static/app.css") would be allowed by the ".css" extension check on line 51, even though "/static/" isn't in the path prefix list. Consider whether both approaches are needed or if one method would be more maintainable and clearer in intent.
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on line 63 has inconsistent indentation. It should be aligned with the surrounding code at the same indentation level as the if statement below it, rather than being flush with the left margin.
| // 2) Allow your public pages (home/about/login/error) | |
| // 2) Allow your public pages (home/about/login/error) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,9 +11,8 @@ | |
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <c:import url="/WEB-INF/jsp/head-meta.jsp" /> | ||
| <link rel="stylesheet" href="${pageContext.request.contextPath}/css/layout.css" /> | ||
|
||
| <link rel="stylesheet" href="${pageContext.request.contextPath}/css/home.css" /> | ||
| </head> | ||
| <body> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new variable 'uri' is introduced on line 39 but it's only used once to derive 'path' on line 40. This adds an unnecessary intermediate variable. Consider removing the 'uri' variable and keeping the original single-line assignment: String path = req.getRequestURI().substring(contextPath.length());