Skip to content

Commit d0718a4

Browse files
ahornaceVladimir Kotal
authored andcommitted
Search endpoint filtered by localhost filter fix
1 parent c1a21bc commit d0718a4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/org/opensolaris/opengrok/web/api/v1/filter/LocalhostFilter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import javax.ws.rs.ext.Provider;
3535
import java.io.IOException;
3636
import java.net.InetAddress;
37+
import java.util.Collections;
3738
import java.util.HashSet;
3839
import java.util.Set;
3940
import java.util.logging.Level;
@@ -45,6 +46,8 @@ public class LocalhostFilter implements ContainerRequestFilter {
4546

4647
private static final Logger logger = LoggerFactory.getLogger(LocalhostFilter.class);
4748

49+
private static final Set<String> allowedPaths = Collections.singleton("search");
50+
4851
@Context
4952
private HttpServletRequest request;
5053

@@ -64,6 +67,11 @@ public void init() {
6467

6568
@Override
6669
public void filter(final ContainerRequestContext context) {
70+
String path = context.getUriInfo().getPath();
71+
if (allowedPaths.contains(path)) {
72+
return;
73+
}
74+
6775
if (!localAddresses.contains(request.getRemoteAddr())) {
6876
context.abortWith(Response.status(Response.Status.UNAUTHORIZED).build());
6977
}

0 commit comments

Comments
 (0)