Skip to content

Commit

Permalink
Merge pull request #25354 from avpinchuk/admin-login
Browse files Browse the repository at this point in the history
Improve HTTP admin login flow
  • Loading branch information
arjantijms authored Jan 27, 2025
2 parents 50b3981 + 0bcf09a commit f87ba31
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2023, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -225,21 +225,24 @@ private boolean ensureGroupMembership(String user, String realm) {

private Subject authenticate(final Request req, final String alternateHostname) throws IOException, LoginException {
final AdminCallbackHandler cbh = new AdminCallbackHandler(habitat, req, alternateHostname, getDefaultAdminUser(), localPassword);
Subject s;
try {
s = authService.login(cbh, null);
/*
* Enforce remote access restrictions, if any.
*/
rejectRemoteAdminIfDisabled(cbh);
consumeTokenIfPresent(req);

Subject subject = consumeTokenIfPresent(req);
if (subject == null) {
subject = authService.login(cbh, null);
}

if (ADMSEC_LOGGER.isLoggable(Level.FINE)) {
ADMSEC_LOGGER.log(Level.FINE, "*** Login worked\n user={0}\n dn={1}\n tkn={2}\n admInd={3}\n host={4}\n",
new Object[] { cbh.pw().getUserName(), cbh.clientPrincipal() == null ? "null" : cbh.clientPrincipal().getName(),
cbh.tkn(), cbh.adminIndicator(), cbh.remoteHost() });
}

return s;
return subject;
} catch (RemoteAdminAccessException ex) {
/*
* Rethrow RemoteAdminAccessException explicitly to avoid it being
Expand Down

0 comments on commit f87ba31

Please sign in to comment.