[java-idp-plugin-totp] branch main updated: JTOTP-17 - Audit log should include a default extractor for username

Scott Cantor cantor.2 at osu.edu
Wed Apr 2 13:10:27 UTC 2025


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-idp-plugin-totp.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-totp.git;a=commit;h=0ba0322126d8a31ed12cbf3ccf0916bc57666eb2

The following commit(s) were added to refs/heads/main by this push:
     new 0ba0322  JTOTP-17 - Audit log should include a default extractor for username
0ba0322 is described below

commit 0ba0322126d8a31ed12cbf3ccf0916bc57666eb2
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Apr 2 09:10:24 2025 -0400

    JTOTP-17 - Audit log should include a default extractor for username
    
    https://shibboleth.atlassian.net/browse/JTOTP-17
---
 .../totp/impl/AttemptedUsernameAuditExtractor.java | 48 ++++++++++++++++++++++
 .../shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml |  9 +++-
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/totp-impl/src/main/java/net/shibboleth/idp/plugin/authn/totp/impl/AttemptedUsernameAuditExtractor.java b/totp-impl/src/main/java/net/shibboleth/idp/plugin/authn/totp/impl/AttemptedUsernameAuditExtractor.java
new file mode 100644
index 0000000..d92eb91
--- /dev/null
+++ b/totp-impl/src/main/java/net/shibboleth/idp/plugin/authn/totp/impl/AttemptedUsernameAuditExtractor.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.idp.plugin.authn.totp.impl;
+
+import java.util.function.Function;
+
+import javax.annotation.Nullable;
+
+import org.opensaml.profile.context.ProfileRequestContext;
+
+import net.shibboleth.idp.authn.context.AuthenticationContext;
+import net.shibboleth.idp.plugin.authn.totp.context.TOTPContext;
+
+/**
+ * {@link Function} that returns the username in a subordinate {@link TOTPContext}, if any.
+ * 
+ * @since 2.3.1
+ */
+public class AttemptedUsernameAuditExtractor implements Function<ProfileRequestContext,String> {
+
+    /** {@inheritDoc} */
+    @Nullable public String apply(@Nullable final ProfileRequestContext input) {
+
+        assert input != null;
+        final AuthenticationContext authnCtx = input.getSubcontext(AuthenticationContext.class);
+        if (authnCtx != null) {
+            final TOTPContext totpContext = authnCtx.getSubcontext(TOTPContext.class);
+            if (totpContext != null) {
+                return totpContext.getUsername();
+            }
+        }
+        
+        return null;
+    }
+    
+}
\ No newline at end of file
diff --git a/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml b/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml
index 3ab56a6..93691cd 100644
--- a/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml
+++ b/totp-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/authn/TOTP/TOTP-beans.xml
@@ -98,7 +98,14 @@
     <bean id="shibboleth.authn.TOTP.DefaultAuditExtractors" parent="shibboleth.authn.DefaultAuditExtractors" lazy-init="true"
             class="org.springframework.beans.factory.config.MapFactoryBean">
         <property name="sourceMap">
-             <map merge="true" />
+             <map merge="true">
+                <entry>
+                    <key>
+                        <util:constant static-field="net.shibboleth.idp.profile.IdPAuditFields.USERNAME"/>
+                    </key>
+                    <bean class="net.shibboleth.idp.plugin.authn.totp.impl.AttemptedUsernameAuditExtractor" />
+                </entry>
+             </map>
         </property>
     </bean>
     

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list