Quarkus OpenApi 将 x-tokenName 扩展添加到 application.properties 中的 SecurityScheme

发布于 2025-01-09 05:27:08 字数 1192 浏览 1 评论 0 原文

我想使用 application.properties 文件将 x-tokenName 扩展添加到 quarkus 中的 openApi 安全方案组件中。我使用微软作为 openIdConnect 的提供者,因此我收到了包含 access_token 和 id_token 的响应。

到目前为止,我的配置看起来像这样:

quarkus.smallrye-openapi.security-scheme=oidc
quarkus.smallrye-openapi.security-scheme-name=OpenId
quarkus.smallrye-openapi.oidc-open-id-connect-url=https://login.microsoftonline.com/${TENANT_ID}/v2.0/.well-known/openid-configuration

相应的 openapi.yaml 查找如下所示的安全方案部分:

components:
  securitySchemes:
    OpenId:
      type: openIdConnect
      description: Authentication
      openIdConnectUrl: https://login.microsoftonline.com/xxxxxxxxxx/v2.0/.well-known/openid-configuration

我没有找到任何可能性,添加具有如下属性(或类似)的 x-tokenName:

quarkus.smallrye-openapi.security-scheme-extension=tokenName:id_token

来实现相应的 openapi .yaml 像这样:

components:
  securitySchemes:
    OpenId:
      type: openIdConnect
      description: Authentication
      openIdConnectUrl: https://login.microsoftonline.com/xxxxxxxxxx/v2.0/.well-known/openid-configuration
      x-tokenName: id_token

据我所知,这些扩展是 openApi 的一部分并且应该可以工作。或者我错过了什么?

I want to add the x-tokenName extension to the openApi security scheme component in quarkus using the application.properties file. I'am using microsoft as provider for openIdConnect, and therefore i got a response containing an access_token and a id_token.

My configuration so far, look somehow like this:

quarkus.smallrye-openapi.security-scheme=oidc
quarkus.smallrye-openapi.security-scheme-name=OpenId
quarkus.smallrye-openapi.oidc-open-id-connect-url=https://login.microsoftonline.com/${TENANT_ID}/v2.0/.well-known/openid-configuration

The corresponding openapi.yaml looks for the security scheme part like this:

components:
  securitySchemes:
    OpenId:
      type: openIdConnect
      description: Authentication
      openIdConnectUrl: https://login.microsoftonline.com/xxxxxxxxxx/v2.0/.well-known/openid-configuration

I did not find any possibility, to add x-tokenName with properties like this (or similiar):

quarkus.smallrye-openapi.security-scheme-extension=tokenName:id_token

to achieve a corresponding openapi.yaml like this:

components:
  securitySchemes:
    OpenId:
      type: openIdConnect
      description: Authentication
      openIdConnectUrl: https://login.microsoftonline.com/xxxxxxxxxx/v2.0/.well-known/openid-configuration
      x-tokenName: id_token

As far as i know, these extension are part of openApi and should work. Or am I missing something?

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

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

发布评论

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

评论(1

偏爱你一生 2025-01-16 05:27:08

通过配置(目前)无法将 x-* 添加到安全模型。但我认为这是一个可以请求的有效功能,因此请在问题中这样做。

您现在可以做的是创建自己的过滤器(这就是它的全部内容)。

请参阅 https://download.eclipse .org/microprofile/microprofile-open-api-1.0/microprofile-openapi-spec.html#_oasfilter

Quarkus 中当前的过滤器:https://github.com/quarkusio/quarkus/blob/main/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/filter/SecurityConfigFilter.java

Adding x-* to the security model is not possible with config (at the moment). But I think that would be a valid feature to request, so please do so in the issues.

What you can do for now is to create your own Filter (that is all that it is under the covers).

See https://download.eclipse.org/microprofile/microprofile-open-api-1.0/microprofile-openapi-spec.html#_oasfilter

And the current filter in Quarkus: https://github.com/quarkusio/quarkus/blob/main/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/filter/SecurityConfigFilter.java

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