Skip to content

Commit afb3e12

Browse files
authored
Merge pull request #1280 from aogburn/03102603
[UNDERTOW-2007] Digest mechanism needs sticky sessions
2 parents 7b5681b + 499ec14 commit afb3e12

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/src/main/java/io/undertow/security/impl/DigestAuthenticationMechanism.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import io.undertow.util.HeaderMap;
4343
import io.undertow.util.Headers;
4444
import io.undertow.util.HexConverter;
45+
import io.undertow.util.Sessions;
4546
import io.undertow.util.StatusCodes;
4647

4748
import java.nio.charset.StandardCharsets;
@@ -445,6 +446,13 @@ private byte[] createRFC2617RequestDigest(final byte[] ha1, final byte[] ha2, fi
445446

446447
@Override
447448
public ChallengeResult sendChallenge(final HttpServerExchange exchange, final SecurityContext securityContext) {
449+
// Ensure a session is created to have stickiness through loadbalancers
450+
try {
451+
Sessions.getOrCreateSession(exchange);
452+
} catch (IllegalStateException e) {
453+
UndertowLogger.SECURITY_LOGGER.debugf("Session error. Digest auth may fail from broken stickiness", e);
454+
}
455+
448456
DigestContext context = exchange.getAttachment(DigestContext.ATTACHMENT_KEY);
449457
boolean stale = context == null ? false : context.isStale();
450458

0 commit comments

Comments
 (0)