You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2026/09/01 08:51:19 UTC
(cxf) branch 3.6.x-fixes updated (c5ab6cbfde7 -> 646d9b72b88)
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a change to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
from c5ab6cbfde7 Add default expiry for JwtAuthenticationClientFilter (#3422)
new 7cec2100b13 Use a properly random source to generate digest client nonces (#3423)
new 646d9b72b88 Require in OidcRpAuthenticationFilter that IdTokens have an expiry (#3424)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../security/oidc/rp/OidcRpAuthenticationFilter.java | 19 +++++++++++++++++--
.../cxf/transport/http/auth/DigestAuthSupplier.java | 12 +++++++++++-
.../transport/http/auth/DigestAuthSupplierTest.java | 14 ++++++++++++++
3 files changed, 42 insertions(+), 3 deletions(-)
(cxf) 01/02: Use a properly random source to generate digest client nonces (#3423)
Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 7cec2100b13ae53098c7e21321426410e560bcc9
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Tue Sep 1 08:27:49 2026 +0100
Use a properly random source to generate digest client nonces (#3423)
(cherry picked from commit b0196449b3561b29924b219ed331a8e85f237f73)
---
.../apache/cxf/transport/http/auth/DigestAuthSupplier.java | 12 +++++++++++-
.../cxf/transport/http/auth/DigestAuthSupplierTest.java | 14 ++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/auth/DigestAuthSupplier.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/auth/DigestAuthSupplier.java
index b076ae3fd7b..6ab3931f90d 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/auth/DigestAuthSupplier.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/auth/DigestAuthSupplier.java
@@ -22,6 +22,7 @@ package org.apache.cxf.transport.http.auth;
import java.net.URI;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
+import java.security.SecureRandom;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -36,6 +37,7 @@ import static java.nio.charset.StandardCharsets.US_ASCII;
*
*/
public class DigestAuthSupplier implements HttpAuthSupplier {
+ private static final SecureRandom CNONCE_GENERATOR = new SecureRandom();
Map<URI, DigestInfo> authInfo = new ConcurrentHashMap<>();
@@ -107,8 +109,16 @@ public class DigestAuthSupplier implements HttpAuthSupplier {
return authURI;
}
+ /**
+ * Creates the client nonce. RFC 7616 relies on the cnonce being unpredictable so
+ * that a hostile or spoofed server controlling the challenge nonce cannot steer
+ * the client into computing a digest over fully attacker-chosen input; a
+ * timestamp is guessable and must not be used here.
+ */
public String createCnonce() {
- return Long.toString(System.currentTimeMillis());
+ byte[] bytes = new byte[16];
+ CNONCE_GENERATOR.nextBytes(bytes);
+ return StringUtils.toHexString(bytes);
}
class DigestInfo {
diff --git a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/auth/DigestAuthSupplierTest.java b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/auth/DigestAuthSupplierTest.java
index 127b88b8856..81e20e4c878 100644
--- a/rt/transports/http/src/test/java/org/apache/cxf/transport/http/auth/DigestAuthSupplierTest.java
+++ b/rt/transports/http/src/test/java/org/apache/cxf/transport/http/auth/DigestAuthSupplierTest.java
@@ -29,6 +29,7 @@ import org.apache.cxf.message.MessageImpl;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
public class DigestAuthSupplierTest {
@@ -92,6 +93,19 @@ public class DigestAuthSupplierTest {
assertEquals(expectedParams, params);
}
+ @Test
+ public void testCnonceIsUnpredictable() throws Exception {
+ DigestAuthSupplier authSupplier = new DigestAuthSupplier();
+ String cnonce1 = authSupplier.createCnonce();
+ String cnonce2 = authSupplier.createCnonce();
+ // 16 random bytes, hex encoded
+ assertEquals(32, cnonce1.length());
+ assertTrue(cnonce1.matches("[0-9a-fA-F]+"));
+ assertNotEquals(cnonce1, cnonce2);
+ // must not be an epoch-millis timestamp
+ assertNotEquals(Long.toString(System.currentTimeMillis()).length(), cnonce1.length());
+ }
+
@Test
public void testUrlEncodedUri() throws Exception {
AuthorizationPolicy authPolicy = new AuthorizationPolicy();
(cxf) 02/02: Require in OidcRpAuthenticationFilter that IdTokens have an expiry (#3424)
Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 646d9b72b882970ffb0bc99d51061956e2d0a746
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Tue Sep 1 08:28:00 2026 +0100
Require in OidcRpAuthenticationFilter that IdTokens have an expiry (#3424)
(cherry picked from commit 639cb574be237b0ba9f3228c35c48008739b5b7e)
---
.../security/oidc/rp/OidcRpAuthenticationFilter.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationFilter.java b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationFilter.java
index 530824174b3..28579c9645e 100644
--- a/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationFilter.java
+++ b/rt/rs/security/sso/oidc/src/main/java/org/apache/cxf/rs/security/oidc/rp/OidcRpAuthenticationFilter.java
@@ -55,6 +55,7 @@ public class OidcRpAuthenticationFilter implements ContainerRequestFilter {
private String redirectUri;
private String roleClaim;
private boolean addRequestUriAsRedirectQuery;
+ private boolean requireIdTokenExpiry = true;
public void filter(ContainerRequestContext rc) {
if (checkSecurityContext(rc)) {
@@ -87,9 +88,13 @@ public class OidcRpAuthenticationFilter implements ContainerRequestFilter {
return false;
}
IdToken idToken = tokenContext.getIdToken();
+ if (idToken == null) {
+ return false;
+ }
try {
- // If ID token has expired then the context is no longer valid
- JwtUtils.validateJwtExpiry(idToken, 0, idToken.getExpiryTime() != null);
+ // If ID token has expired then the context is no longer valid.
+ // OIDC Core mandates "exp" in ID Tokens, so it is required by default.
+ JwtUtils.validateJwtExpiry(idToken, 0, requireIdTokenExpiry);
} catch (JwtException ex) {
stateManager.removeClientTokenContext(new MessageContextImpl(JAXRSUtils.getCurrentMessage()));
return false;
@@ -154,4 +159,14 @@ public class OidcRpAuthenticationFilter implements ContainerRequestFilter {
public void setAddRequestUriAsRedirectQuery(boolean addRequestUriAsRedirectQuery) {
this.addRequestUriAsRedirectQuery = addRequestUriAsRedirectQuery;
}
+
+ /**
+ * Whether the stored ID token must carry an expiry ("exp") claim for the
+ * session context to keep being revalidated. Default is true. Disabling
+ * this re-opens never-expiring sessions for exp-less ID tokens - only do
+ * so if another mechanism bounds the session lifetime.
+ */
+ public void setRequireIdTokenExpiry(boolean requireIdTokenExpiry) {
+ this.requireIdTokenExpiry = requireIdTokenExpiry;
+ }
}