[
https://issues.apache.org/jira/browse/KNOX-3073?focusedWorklogId=942881&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-942881
]
ASF GitHub Bot logged work on KNOX-3073:
----------------------------------------
Author: ASF GitHub Bot
Created on: 08/Nov/24 20:39
Start Date: 08/Nov/24 20:39
Worklog Time Spent: 10m
Work Description: pzampino commented on code in PR #949:
URL: https://github.com/apache/knox/pull/949#discussion_r1835034993
##########
gateway-provider-security-jwt/src/main/java/org/apache/knox/gateway/provider/federation/jwt/filter/AbstractJWTFilter.java:
##########
@@ -512,17 +520,22 @@ protected boolean verifyTokenSignature(final JWT token) {
// If it has not yet been verified, then perform the verification now
if (!verified) {
try {
+ boolean hasPem = false;
+ boolean hasJWKS = false;
+
if (publicKey != null) {
+ hasPem = true;
verified = authority.verifyToken(token, publicKey);
log.pemVerificationResultMessage(verified);
}
if (!verified && expectedJWKSUrls != null &&
!expectedJWKSUrls.isEmpty()) {
+ hasJWKS = true;
verified = authority.verifyToken(token, expectedJWKSUrls,
expectedSigAlg, allowedJwsTypes);
log.jwksVerificationResultMessage(verified);
}
- if(!verified) {
+ if(!verified && ((!hasPem && !hasJWKS) || isJwtInstanceKeyFallback)) {
Review Comment:
@smolnar82 Thank you for the thoughtful review. I've made the agreed upon
changes.
Issue Time Tracking
-------------------
Worklog Id: (was: 942881)
Time Spent: 1h (was: 50m)
> Token verification fallback to Knox keys behavior should configurable
> ---------------------------------------------------------------------
>
> Key: KNOX-3073
> URL: https://issues.apache.org/jira/browse/KNOX-3073
> Project: Apache Knox
> Issue Type: Improvement
> Components: Server
> Reporter: Philip Zampino
> Assignee: Philip Zampino
> Priority: Major
> Time Spent: 1h
> Remaining Estimate: 0h
>
> KNOX-3040
> ntroduced support for multiple token verification mechanisms (i.e., PEM,
> jwks) for the same topology (provider instance), falling back to Knox's own
> signing and TLS keys if any of those configured should fail.
> This behavior may not be expected by some, and we should provide the ability
> to control the fallback to the Knox keys.
> To support deployments expecting the previous behavior, there should be a
> provider param for indicating that the new fall-back behavior is desired
> (e.g., instance-keys-fallback=true), which defaults to false.
> Default Behavior:
> * Neither PEM nor jwks URL(s) is configured, attempt verification using (in
> order)
> ** Knox's signing key
> ** Knox's TLS key
> * Only PEM is configured: Knox will attempt verification using ONLY the
> configured PEM
> * Only jwks URL(s) are configured: Knox will attempt verification using ONLY
> the configured jwks URL(s)
> * PEM AND jwks URL(s) are configured: Knox will attempt verification using
> ONLY (in order)
> ** The configured PEM
> ** The configured jwks URL(s).
> instance-keys-fallback=true Behavior:
> * Same as default behavior except that in the cases where PEM and/or jwks
> URL(s) are configured and fail to verify, Knox will subsequently attempt
> verification using (in order):
> ** Knox's signing key
> ** Knox's TLS key
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)