-
Notifications
You must be signed in to change notification settings - Fork 54
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
Doesn't seem to work with sbt #18
Comments
Thanks for reporting. Indeed, adding a realm isn't that hard. I'll look into this asap! |
We'd just need to add a login-config to the web.xml IMO :
|
Thanks for the fast response! |
Very weird. I'm AFK right now, will look into this asap. |
It has to be in the <?xml version="1.0" encoding="utf-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<servlet>
<servlet-name>jerseyServlet</servlet-name>
<servlet-class>
org.glassfish.jersey.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>repo.Application</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jerseyServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>everything</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>/_ah/start</web-resource-name>
<url-pattern>/_ah/start</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>my-realm-name</realm-name>
</login-config>
</web-app>
|
Looks correct. So, still no realm? |
No, unfortunately not |
Well, I've got it working with a very dirty workaround. I created the class package repo.provider;
import java.io.IOException;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
public class ResponseServerFilter implements ContainerResponseFilter {
@Override
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
responseContext.getHeaders().remove("WWW-Authenticate");
responseContext.getHeaders().add("WWW-Authenticate", "Basic realm=\"my-realm-name\"");
}
} and registered it in public Application() throws IOException {
...
register(ResponseServerFilter.class);
...
} So the server just automatically replaces the I think some parts of the Basic-Auth implementation are a bit odd, because the |
Weird.... |
I couldn't get this project to work properly with sbt.
I'm fairly certain that it has something to do with the Basic Auth, because you are forced to define a realm for the credentials in sbt, but this project doesn't return any.
curl https://maven.company.com -vv
returnsWWW-Authenticate: Basic
instead ofWWW-Authenticate: Basic realm="some-realm-name"
I have already commented an open issue on sbt describing the problem (link)
However, i do believe that it would be fairly simple to just return a realm in this application.
Unfortunately, i wasn't able to do it myself, because i lack knowledge about JAX-RS.
The text was updated successfully, but these errors were encountered: