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

[#233] Prevent logging of invalid login credentials #234

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fix configuration for delegated authentication with OIDC [#222]
- Prevent logging of invalid login credentials [#233]

## [v7.0.8-3] - 2024-10-11
### Changed
Expand Down
7 changes: 7 additions & 0 deletions app/etc/cas/config/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<LoggingHandlerPasswordRewritePolicy />
<AppenderRef ref="casConsole" />
</Rewrite>
<Rewrite name="misspelledPasswordRewritePolicy" >
<MisspelledPasswordRewritePolicy />
<AppenderRef ref="casConsole" />
</Rewrite>
</Appenders>
<Loggers>
<!-- If adding a Logger with level set higher than ${sys:ces.log.level}, make category as selective as possible -->
Expand Down Expand Up @@ -104,6 +108,9 @@
<AsyncLogger name="io.netty.handler.logging.LoggingHandler" level="${sys:ces.log.level}" includeLocation="true" additivity="false">
<AppenderRef ref="loggingHandlerPasswordRewritePolicy"/>
</AsyncLogger>
<AsyncLogger name="org.apereo.cas.web.flow.DefaultDelegatedClientIdentityProviderConfigurationProducer" level="${sys:ces.log.level}" includeLocation="true" additivity="false">
<AppenderRef ref="misspelledPasswordRewritePolicy"/>
</AsyncLogger>

<!-- All Loggers inherit appenders specified here, unless additivity="false" on the Logger -->
<AsyncRoot level="${sys:ces.log.level}">
Expand Down
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;
}
}
7 changes: 7 additions & 0 deletions resources/etc/cas/config/log4j2.xml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<LoggingHandlerPasswordRewritePolicy />
<AppenderRef ref="casConsole" />
</Rewrite>
<Rewrite name="misspelledPasswordRewritePolicy" >
<MisspelledPasswordRewritePolicy />
<AppenderRef ref="casConsole" />
</Rewrite>
</Appenders>
<Loggers>
<!-- If adding a Logger with level set higher than ${sys:ces.log.level}, make category as selective as possible -->
Expand Down Expand Up @@ -104,6 +108,9 @@
<AsyncLogger name="io.netty.handler.logging.LoggingHandler" level="${sys:ces.log.level}" includeLocation="true" additivity="false">
<AppenderRef ref="loggingHandlerPasswordRewritePolicy"/>
</AsyncLogger>
<AsyncLogger name="org.apereo.cas.web.flow.DefaultDelegatedClientIdentityProviderConfigurationProducer" level="${sys:ces.log.level}" includeLocation="true" additivity="false">
<AppenderRef ref="misspelledPasswordRewritePolicy"/>
</AsyncLogger>

<!-- All Loggers inherit appenders specified here, unless additivity="false" on the Logger -->
<AsyncRoot level="${sys:ces.log.level}">
Expand Down