-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#233] Prevent logging of invalid login credentials
because the DefaultDelegatedClientIdentityProviderConfigurationProducer of apereo.cas would print invalid credentials at an invalid login attempt, the password in the log event need to be masked to prevent guessing of actual credentials
- Loading branch information
Marco Bergen
committed
Nov 13, 2024
1 parent
d4c3bce
commit d931e9c
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/de/triology/cas/logging/MisspelledPasswordRewritePolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.triology.cas.logging; | ||
|
||
import org.apache.logging.log4j.core.config.plugins.Plugin; | ||
import org.apache.logging.log4j.core.config.plugins.PluginFactory; | ||
|
||
@Plugin( | ||
name = "MisspelledPasswordRewritePolicy", | ||
category = "Core", | ||
elementType = "rewritePolicy", | ||
printObject = true | ||
) | ||
/* | ||
* Password rewriter for class org.apereo.cas.web.flow.DefaultDelegatedClientIdentityProviderConfigurationProducer. | ||
*/ | ||
public final class MisspelledPasswordRewritePolicy extends AbstractCASPasswordRewritePolicy { | ||
private static final String PARAMETER_PASSWORD_TEXT = "password="; | ||
|
||
@PluginFactory | ||
public static MisspelledPasswordRewritePolicy createPolicy() { | ||
return new MisspelledPasswordRewritePolicy(); | ||
} | ||
|
||
private MisspelledPasswordRewritePolicy() { | ||
// | ||
} | ||
|
||
@Override | ||
protected String getPasswordFlag() { | ||
return PARAMETER_PASSWORD_TEXT; | ||
} | ||
|
||
@Override | ||
protected String replacePasswordValue(String originMessage) { | ||
String truncatedMessage = null; | ||
|
||
if (originMessage != null) { | ||
truncatedMessage = originMessage.replaceAll("password=\\[.*\\],\\s*exec", "password=[******], exec"); | ||
} | ||
|
||
return truncatedMessage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters