Skip to content
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

Fix for JBEAP-11680: Kerberos negotiation done in every request #37

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static io.undertow.util.Headers.NEGOTIATE;
import static io.undertow.util.Headers.WWW_AUTHENTICATE;
import static io.undertow.util.StatusCodes.UNAUTHORIZED;
import io.undertow.security.api.AuthenticatedSessionManager;
import io.undertow.security.api.AuthenticationMechanism;
import io.undertow.security.api.SecurityContext;
import io.undertow.security.idm.Account;
Expand Down Expand Up @@ -89,6 +90,18 @@ public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange,
return AuthenticationMechanismOutcome.NOT_AUTHENTICATED;
}

Account account = null;
AuthenticatedSessionManager sessionManager = (AuthenticatedSessionManager)exchange.getAttachment(AuthenticatedSessionManager.ATTACHMENT_KEY);
if (sessionManager != null) {
AuthenticatedSessionManager.AuthenticatedSession authSession = sessionManager.lookupSession(exchange);
if (authSession != null) {
account = authSession.getAccount();
if (account != null && account.getPrincipal() != null) {
negContext.setUsername(account.getPrincipal().getName());
}
}
}

String username = negContext.getUsername();
if (username == null || username.length() == 0) {
username = UUID.randomUUID().toString();
Expand All @@ -98,7 +111,11 @@ public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange,
IdentityManager identityManager = getIdentityManager(securityContext);
try {
negContext.associate();
final Account account = identityManager.verify(username, null);
if (account != null) {
account = identityManager.verify(account);
} else {
account = identityManager.verify(username, null);
}
if (account != null) {
securityContext.authenticationComplete(account, "SPNEGO", true);

Expand Down