Skip to content

Commit

Permalink
codeine-226 /metrics on the server should be with no auth
Browse files Browse the repository at this point in the history
  • Loading branch information
rezra3 committed Mar 5, 2018
1 parent 5c6238e commit a1f740f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
28 changes: 13 additions & 15 deletions src/web_server/codeine/CodeineWebServerBootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,6 @@ private ServletContextHandler createServletContextHandlerSpnego() {
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS
| ServletContextHandler.SECURITY);

Constraint constraint = new Constraint();
constraint.setName(Constraint.__SPNEGO_AUTH);
constraint.setRoles(config.get().roles());
constraint.setAuthenticate(true);

ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");

ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler() {
@Override
public void handle(String pathInContext, Request baseRequest,
Expand All @@ -170,6 +161,15 @@ public void handle(String pathInContext, Request baseRequest,
}
};

Constraint constraint = new Constraint();
constraint.setName(Constraint.__SPNEGO_AUTH);
constraint.setRoles(config.get().roles());
constraint.setAuthenticate(true);

ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/*");

Constraint constraint2 = new Constraint();
constraint2.setAuthenticate(false);
constraint2.setName("reporter");
Expand All @@ -189,15 +189,13 @@ public void handle(String pathInContext, Request baseRequest,
Constraint constraint4 = new Constraint();
constraint4.setAuthenticate(false);
constraint4.setName("prometheus");
constraint4.setRoles(config.get().roles());
ConstraintMapping constraintMapping4 = new ConstraintMapping();
constraintMapping4.setConstraint(constraint4);
constraintMapping4.setPathSpec(Constants.apiContext(Constants.METRICS_CONTEXT));
constraintMapping4.setPathSpec(Constants.METRICS_CONTEXT);

securityHandler.addConstraintMapping(constraintMapping4);
securityHandler.addConstraintMapping(constraintMapping3);
securityHandler.addConstraintMapping(constraintMapping2);
securityHandler.addConstraintMapping(constraintMapping);
securityHandler.setConstraintMappings(Lists
.newArrayList(constraintMapping4, constraintMapping3, constraintMapping2,
constraintMapping));
SpnegoLoginService loginService = new SpnegoLoginService(null,
Constants.getSpnegoPropertiesPath());
securityHandler.setLoginService(loginService);
Expand Down

0 comments on commit a1f740f

Please sign in to comment.