-
Notifications
You must be signed in to change notification settings - Fork 559
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved execution of servlet to the filter chain to allow filters to ha…
…lt execution. The servlet is injected in the chain by the FilterChainManager. This should fix the last issues with #65 and fix #66
- Loading branch information
Showing
12 changed files
with
279 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...park/src/test/java/com/amazonaws/serverless/proxy/spark/filter/UnauthenticatedFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.amazonaws.serverless.proxy.spark.filter; | ||
|
||
|
||
import javax.servlet.Filter; | ||
import javax.servlet.FilterChain; | ||
import javax.servlet.FilterConfig; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.ServletRequest; | ||
import javax.servlet.ServletResponse; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
public class UnauthenticatedFilter implements Filter { | ||
public static final String HEADER_NAME = "X-Unauthenticated-Response"; | ||
public static final int RESPONSE_STATUS = 401; | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) | ||
throws ServletException { | ||
|
||
} | ||
|
||
|
||
@Override | ||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) | ||
throws IOException, ServletException { | ||
System.out.println("Running unauth filter"); | ||
if (((HttpServletRequest)servletRequest).getHeader(HEADER_NAME) != null) { | ||
((HttpServletResponse) servletResponse).setStatus(401); | ||
System.out.println("Returning 401"); | ||
return; | ||
} | ||
System.out.println("Continue chain"); | ||
filterChain.doFilter(servletRequest, servletResponse); | ||
} | ||
|
||
|
||
@Override | ||
public void destroy() { | ||
|
||
} | ||
} |
Oops, something went wrong.