Skip to content

Commit 665c7fd

Browse files
committed
NIFI-7924: review feedback addressed
1 parent 99a6009 commit 665c7fd

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ public String getOidcClaimIdentifyingUser() {
10201020
public List<String> getOidcFallbackClaimsIdentifyingUser() {
10211021
String rawProperty = getProperty(SECURITY_USER_OIDC_FALLBACK_CLAIMS_IDENTIFYING_USER, "").trim();
10221022
if (rawProperty.isEmpty()) {
1023-
return new ArrayList<>();
1023+
return Collections.emptyList();
10241024
} else {
10251025
List<String> fallbackClaims = Arrays.asList(rawProperty.split(","));
10261026
return fallbackClaims.stream().map(String::trim).collect(Collectors.toList());

nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/main/java/org/apache/nifi/web/security/oidc/StandardOidcIdentityProvider.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,10 @@ private LoginAuthenticationToken convertOIDCTokenToLoginAuthenticationToken(OIDC
440440
logger.info("The 'email' claim was present. Using that claim to avoid extra remote call");
441441
} else {
442442
final List<String> fallbackClaims = properties.getOidcFallbackClaimsIdentifyingUser();
443-
if (fallbackClaims.size() > 0) {
444-
logger.info("fallbackClaims.size() : " + fallbackClaims.size());
445-
for (String fallbackClaim : fallbackClaims) {
446-
if (availableClaims.contains(fallbackClaim)) {
447-
identity = claimsSet.getStringClaim(fallbackClaim);
448-
break;
449-
}
443+
for (String fallbackClaim : fallbackClaims) {
444+
if (availableClaims.contains(fallbackClaim)) {
445+
identity = claimsSet.getStringClaim(fallbackClaim);
446+
break;
450447
}
451448
}
452449
if (StringUtils.isBlank(identity)) {

nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/groovy/org/apache/nifi/web/security/oidc/StandardOidcIdentityProviderGroovyTest.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,9 @@ class StandardOidcIdentityProviderGroovyTest extends GroovyTestCase {
415415
void testconvertOIDCTokenToLoginAuthenticationTokenShouldHandleNoEmailClaimHasFallbackClaims() {
416416
// Arrange
417417
StandardOidcIdentityProvider soip = buildIdentityProviderWithMockTokenValidator(["getOidcClaimIdentifyingUser": "email", "getOidcFallbackClaimsIdentifyingUser": ["upn"] ])
418+
String expectedUpn = "xxx@aaddomain";
418419

419-
OIDCTokenResponse mockResponse = mockOIDCTokenResponse(["email": null, "upn": "xxx@aaddomain"])
420+
OIDCTokenResponse mockResponse = mockOIDCTokenResponse(["email": null, "upn": expectedUpn])
420421
logger.info("OIDC Token Response with no email and upn: ${mockResponse.dump()}")
421422

422423
String loginToken = soip.convertOIDCTokenToLoginAuthenticationToken(mockResponse)
@@ -425,7 +426,7 @@ class StandardOidcIdentityProviderGroovyTest extends GroovyTestCase {
425426
// Split JWT into components and decode Base64 to JSON
426427
def (String contents, String expiration) = loginToken.tokenize("\\[\\]")
427428
logger.info("Token contents: ${contents} | Expiration: ${expiration}")
428-
assert contents =~ "LoginAuthenticationToken for xxx@aaddomain issued by https://accounts\\.issuer\\.com expiring at"
429+
assert contents =~ "LoginAuthenticationToken for ${expectedUpn} issued by https://accounts\\.issuer\\.com expiring at"
429430

430431

431432
}

0 commit comments

Comments
 (0)