Skip to content

Instantly share code, notes, and snippets.

@jenslohmann
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jenslohmann/56a810a2addcd2250b3b to your computer and use it in GitHub Desktop.
Save jenslohmann/56a810a2addcd2250b3b to your computer and use it in GitHub Desktop.
Patch for JBoss 6.1.0.Final (or rather its JBossWeb 3.0.0.CR2) to return a crippled WWW-Authenticate header for XMLHttpRequests
Index: org/apache/catalina/authenticator/BasicAuthenticator.java
<+>UTF-8
===================================================================
--- org/apache/catalina/authenticator/BasicAuthenticator.java (revision )
+++ org/apache/catalina/authenticator/BasicAuthenticator.java (revision )
@@ -191,6 +191,11 @@
request.getResponse().getCoyoteResponse().getMimeHeaders()
.addValue(AUTHENTICATE_BYTES, 0, AUTHENTICATE_BYTES.length);
CharChunk authenticateCC = authenticate.getCharChunk();
+ MessageBytes xRequestedWith =
+ request.getCoyoteRequest().getMimeHeaders().getValue("x-requested-with");
+ if(xRequestedWith != null && xRequestedWith.equals("XMLHttpRequest")) {
+ authenticateCC.append('x');
+ }
authenticateCC.append("Basic realm=\"");
if (config.getRealmName() == null) {
authenticateCC.append("Realm");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment