fix(gateway-vertx): handle failure better for discovery
@@ -103,7 +103,8 @@ public class KeycloakOAuthFactory {
OAuth2ClientOptions options = buildClientOptions(authConfig);
KeycloakAuth.discover(vertx, options, (AsyncResult<OAuth2Auth> result) -> {
- var oauth2 = result.result();
+ if (result.succeeded()) {
+ OAuth2Auth oauth2 = result.result();
oauth2.authenticate(params, tokenResult -> {
if (tokenResult.succeeded()) {
log.debug("OAuth2 Keycloak exchange succeeded.");
@@ -123,6 +124,10 @@ public class KeycloakOAuthFactory {
handle401(context, "invalid_token", message);
}
});
+ } else {
+ log.error("Failure during discovery", result.cause());
+ handle400(context, result.cause().getMessage());
+ }
});
}
@@ -198,7 +203,7 @@ public class KeycloakOAuthFactory {
// HTTP Client Options
if (config.containsKey("ssl-required")) {
- if (!config.getString("ssl-required").toLowerCase().equals("none")) {
+ if (!config.getString("ssl-required").equalsIgnoreCase("none")) {
options.setSsl(true);
}
}
