我已经使用 vert.x 框架中的访问令牌实现了通过不记名身份验证对 Keycloak 的用户信息端点进行保护的后端调用。我能够运行这段代码,没有任何错误。 但我收到这个警告:
> May 16, 2022 10:33:04 AM
io.vertx.ext.auth.oauth2.impl.OAuth2AuthProviderImpl WARNING: Skipped
> unsupported JWK: java.security.NoSuchAlgorithmException: RSA-OAEP
以下是代码:
> OAuth2ClientOptions clientOptions = new OAuth2ClientOptions()
> .setFlow(OAuth2FlowType.AUTH_CODE)
> .setSite(System.getProperty("oauth2.issuer", "http://localhost:8080/auth/realms/myrealm"))
> .setClientID(System.getProperty("oauth2.client_id", "myclientid"))
> .setClientSecret(System.getProperty("oauth2.client_secret",
> "myclientscret"));
>
> private Handler<RoutingContext> UserInfo(WebClient webClient, String
> userInfoUrl) {
>
> return (RoutingContext ctx) -> {
>
> OAuth2TokenImpl user = (OAuth2TokenImpl) ctx.user();
>
> URI userInfoEndpointUri = URI.create(userInfoUrl);
> webClient
> .get(userInfoEndpointUri.getPort(), userInfoEndpointUri.getHost(), userInfoEndpointUri.getPath())
> .bearerTokenAuthentication(user.opaqueAccessToken())
> .as(BodyCodec.jsonObject())
> .send(ar -> {
> JsonObject body = ar.result().body();
> respondWithOk(ctx, "application/json", body.encodePrettily());
> });
> };
> }
依赖关系如下:
> <dependencies>
> <dependency>
> <groupId>io.vertx</groupId>
> <artifactId>vertx-auth-oauth2</artifactId>
> <version>3.9.1</version>
> </dependency>
> <dependency>
> <groupId>io.vertx</groupId>
> <artifactId>vertx-core</artifactId>
> <version>3.9.1</version>
> </dependency>
> <dependency>
> <groupId>io.vertx</groupId>
> <artifactId>vertx-web</artifactId>
> <version>3.9.1</version>
> </dependency>
> <dependency>
> <groupId>io.vertx</groupId>
> <artifactId>vertx-web-client</artifactId>
> <version>3.9.1</version>
> </dependency>
> <dependency>
> <groupId>io.vertx</groupId>
> <artifactId>vertx-auth-jwt</artifactId>
> <version>3.9.1</version>
> </dependency>
> </dependencies>
如何解决此警告?
您可以忽略此警告,它只是故意警告。
因为现在会抛出
RuntimeException
,您可能想要禁用密钥提供程序:
Realm settings > Keys > Providers
rsa-enc-generated
:将 enabled
和 active
切换为关闭在一种情况下,
rsa-enc-generated
已被设置为禁用/停用。当我再次打开和关闭它并单击保存按钮时,提供程序实际上已被禁用并且错误消失了。但在后来的实例中,它被正确显示为已启用/活动,我必须禁用它才能修复错误。