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

Fix NPE when OIDC TenantConfigResolver returns null #32481

Merged
merged 1 commit into from
Apr 6, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ private void useTenantConfigResolver() throws IOException, InterruptedException

assertEquals("tenant-config-resolver:alice", page.getBody().asNormalizedText());
webClient.getCookieManager().clearCookies();
try {
webClient.getPage("http://localhost:8080/protected/tenant/null-tenant");
fail("401 status error is expected");
} catch (FailingHttpStatusCodeException ex) {
assertEquals(401, ex.getStatusCode());
}
try {
webClient.getPage("http://localhost:8080/protected/tenant/unknown-tenant");
fail("401 status error is expected");
} catch (FailingHttpStatusCodeException ex) {
assertEquals(401, ex.getStatusCode());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public Uni<OidcTenantConfig> resolve(RoutingContext context, OidcRequestContext<
config.setApplicationType(ApplicationType.WEB_APP);
return Uni.createFrom().item(config);
}
if (context.request().path().endsWith("/null-tenant")) {
return null;
}
return Uni.createFrom().nullItem();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@ private Uni<OidcTenantConfig> getDynamicTenantConfig(RoutingContext context) {
if (tenantConfigResolver.isResolvable()) {
Uni<OidcTenantConfig> oidcConfig = context.get(CURRENT_DYNAMIC_TENANT_CONFIG);
if (oidcConfig == null) {
oidcConfig = tenantConfigResolver.get().resolve(context, blockingRequestContext).memoize().indefinitely();
oidcConfig = tenantConfigResolver.get().resolve(context, blockingRequestContext);
if (oidcConfig == null) {
//shouldn't happen, but guard against it anyway
oidcConfig = Uni.createFrom().nullItem();
}
oidcConfig = oidcConfig.memoize().indefinitely();
if (oidcConfig == null) {
//shouldn't happen, but guard against it anyway
oidcConfig = Uni.createFrom().nullItem();
Expand Down