mraible commented on code in PR #364:
URL: https://github.com/apache/roller/pull/364#discussion_r4682606816
##########
app/src/main/java/org/apache/roller/weblogger/ui/core/security/RollerPasswordEncoders.java:
##########
@@ -137,13 +165,39 @@ public String encode(CharSequence rawPassword) {
@Override
public boolean matches(CharSequence rawPassword, String
encodedPassword) {
+ if (rawPassword == null || rawPassword.length() == 0) {
+ return false;
+ }
+ Set<String> markers = externalLoginMarkers();
// a stored marker is checked before the delegate sees it, since a
// marker such as {noop}secret would otherwise match its own suffix
- if (rawPassword == null || rawPassword.length() == 0 ||
isExternalLoginMarker(rawPassword)
- || isExternalLoginMarker(encodedPassword)) {
+ if (markers.contains(encodedPassword)) {
+ return false;
+ }
+ if (markers.contains(rawPassword.toString())) {
+ logRefusal();
+ return false;
+ }
+ if (!delegate.matches(rawPassword, encodedPassword)) {
return false;
}
- return delegate.matches(rawPassword, encodedPassword);
+ // BCrypt, for one, treats some other passwords as equal to a
+ // marker, so refuse any password whose stored value a marker
+ // matches too
+ for (String marker : markers) {
Review Comment:
Done in bf431eec7: the marker loop now runs only when the password contains
a NUL or is at least 72 UTF-8 bytes, so other logins skip the extra hashes. On
master, BCrypt refuses passwords over 72 bytes, so in practice only the NUL
case reaches the loop. The sameKey test still covers it.
##########
app/src/main/java/org/apache/roller/weblogger/ui/core/security/RollerPasswordEncoders.java:
##########
@@ -137,13 +165,39 @@ public String encode(CharSequence rawPassword) {
@Override
public boolean matches(CharSequence rawPassword, String
encodedPassword) {
+ if (rawPassword == null || rawPassword.length() == 0) {
Review Comment:
Added the guard in bf431eec7, with a test for null and empty stored values.
Spring Security 7.2 already returns false for both rather than throwing, so
this doesn't change behaviour today, but it keeps master in line with #306
whatever the delegate does.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]