Commit a1978314 authored by Dave Cridland's avatar Dave Cridland Committed by daryl herzmann

OF-1278 Do not be such an idiot while recursing (#751)

* OF-1278 Recurse more sensibly in SCRAM code

Previously, we called setPassword if (and only if) there was a plaintext password present AND the configuration was for SCRAM hashed passwords only.

However, we would then retest to see if there was a salt present, and then recurse, if there was a plaintext password present.

This meant that if there were pre-existing users (with only plaintext or encrypted passwords) but with no SCRAM information, and the userInfo.salt was unset, recursion would continue indefinitely.

* OF-1278 Recurse more sensibly in SCRAM code

This patch further proofs against infinite recursion, and is more aggressive about SCRAMming pre-existing users.

Recursion is now prevented from being more than one deep, as designed.
parent 0f15343c
...@@ -74,6 +74,9 @@ public class DefaultAuthProvider implements AuthProvider { ...@@ -74,6 +74,9 @@ public class DefaultAuthProvider implements AuthProvider {
} }
private UserInfo getUserInfo(String username) throws UnsupportedOperationException, UserNotFoundException { private UserInfo getUserInfo(String username) throws UnsupportedOperationException, UserNotFoundException {
return getUserInfo(username, false);
}
private UserInfo getUserInfo(String username, boolean recurse) throws UnsupportedOperationException, UserNotFoundException {
if (!isScramSupported()) { if (!isScramSupported()) {
// Reject the operation since the provider does not support SCRAM // Reject the operation since the provider does not support SCRAM
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
...@@ -104,15 +107,15 @@ public class DefaultAuthProvider implements AuthProvider { ...@@ -104,15 +107,15 @@ public class DefaultAuthProvider implements AuthProvider {
// Ignore and return plain password instead. // Ignore and return plain password instead.
} }
} }
if (userInfo.plainText != null) { if (!recurse) {
boolean scramOnly = JiveGlobals.getBooleanProperty("user.scramHashedPasswordOnly"); if (userInfo.plainText != null) {
if (scramOnly) { boolean scramOnly = JiveGlobals.getBooleanProperty("user.scramHashedPasswordOnly");
// If we have a password here, but we're meant to be scramOnly, we should reset it. if (scramOnly || userInfo.salt == null) {
setPassword(username, userInfo.plainText); // If we have a password here, but we're meant to be scramOnly, we should reset it.
} setPassword(username, userInfo.plainText);
if (userInfo.salt == null) { // RECURSE
// RECURSE return getUserInfo(username, true);
return getUserInfo(username); }
} }
} }
// Good to go. // Good to go.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment