在Vert.x中获取警告为Nosuchalgorithmexception

发布于 2025-01-29 03:59:03 字数 2952 浏览 3 评论 0原文

我已经使用vert.x Framework中的访问令牌实现了通过携带者身份验证对KeyCloak的UserInfo端点进行保护的后端调用。我可以在没有任何错误的情况下运行此代码。 但是我会收到此警告:

> 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>

如何解决此警告?

I have implemented a backend call protected via bearer authentication to the Keycloak's userinfo endpoint using access token in vert.x framework. I am able to run this code without any errors.
But I am getting this warning:

> May 16, 2022 10:33:04 AM
io.vertx.ext.auth.oauth2.impl.OAuth2AuthProviderImpl WARNING: Skipped
> unsupported JWK: java.security.NoSuchAlgorithmException: RSA-OAEP

Below is the code:

> 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 are as follows:

> <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>

How to resolve this warning?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感悟人生的甜 2025-02-05 03:59:03

由于现在将RuntimeException抛出,您可能需要禁用密钥提供商:

  • Open KeyCloak管理员,请选择使用的领域,
  • 转到realm settings&gt;钥匙&gt;提供商
  • 单击rsa-enc-enerated:switch 启用active

在一个实例中, RSA-ANC-INERED已经设置为禁用/停用。当我再次设置它并按下“保存”按钮时,提供商实际上被禁用,并且错误消失了。但是在以后的实例中,它被正确显示为已启用/活动,我必须将其禁用以修复错误。

As this now throws a RuntimeException you might want to disable the key provider:

  • open Keycloak Admin, select the Realm used
  • go to Realm settings > Keys > Providers
  • click on rsa-enc-generated: switch enabled and active to off

In one instance, rsa-enc-generated was already set to disabled/deactivated. When I set it on and off again and hit the save button, the provider is actually disabled and the error disappears. But in a later instance it was correctly shown as enabled/active and I had to disable it to fix the error.

巨坚强 2025-02-05 03:59:03

您可以忽略此警告,它是仅是故意的警告

You can ignore this warning, it is just a warning on purpose.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文