Skip to content

Commit

Permalink
Merge pull request #1280 from aogburn/03102603
Browse files Browse the repository at this point in the history
[UNDERTOW-2007] Digest mechanism needs sticky sessions
  • Loading branch information
fl4via committed Feb 6, 2022
2 parents 7b5681b + 499ec14 commit afb3e12
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -42,6 +42,7 @@
import io.undertow.util.HeaderMap;
import io.undertow.util.Headers;
import io.undertow.util.HexConverter;
import io.undertow.util.Sessions;
import io.undertow.util.StatusCodes;

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

@Override
public ChallengeResult sendChallenge(final HttpServerExchange exchange, final SecurityContext securityContext) {
// Ensure a session is created to have stickiness through loadbalancers
try {
Sessions.getOrCreateSession(exchange);
} catch (IllegalStateException e) {
UndertowLogger.SECURITY_LOGGER.debugf("Session error. Digest auth may fail from broken stickiness", e);
}

DigestContext context = exchange.getAttachment(DigestContext.ATTACHMENT_KEY);
boolean stale = context == null ? false : context.isStale();

Expand Down

0 comments on commit afb3e12

Please sign in to comment.