简体   繁体   English

是否可以将 Micronaut OAuth2 callback-uri 设置为绝对 URL?

[英]Is it possible to set the Micronaut OAuth2 callback-uri as an absolute URL?

I have a Micronaut web-app that uses OpenId / OAuth2 / JWT.我有一个使用 OpenId/OAuth2/JWT 的 Micronaut 网络应用程序。 In some environments, everything works really well with this set up, however, in other environments, auth fails during the step where the configured callback-uri is called.在某些环境中,使用此设置一切正常,但是,在其他环境中,身份验证在调用配置的 callback-uri 的步骤中失败。 For some reason, in these environments, the URL generated is "http" instead of "https".出于某种原因,在这些环境中,生成的 URL 是“http”而不是“https”。 This causes the call to fail since my application is only accessible over https.这会导致调用失败,因为我的应用程序只能通过 https 访问。

I have no clue why it is trying to use http in the first place, however, if I was able to specify the callback-uri as an absolute / full URL, then I could probably work around this anomaly in these environments.我不知道为什么它首先尝试使用 http,但是,如果我能够将 callback-uri 指定为绝对/完整 URL,那么我可能可以在这些环境中解决这个异常。

An example yml config that I use:我使用的示例 yml 配置:

  application:
    name: xxxxx
  security:
    authentication: idtoken
    oauth2:
      enabled: true
      clients:
        azure:
          client-id: ${OAUTH_CLIENT_ID}
          client-secret: ${OAUTH_CLIENT_SECRET}
          openid:
            issuer: https://login.microsoftonline.com/xxx
      callback-uri: ${OAUTH_CALLBACK_URI}
    redirect:
      login-success: ${LOGIN_SUCCESS_URL}
      logout: '/logout-handler/logout-success'
    endpoints:
      logout:
        get-allowed: true
    token:
      jwt:
        cookie:
          cookie-same-site: none
          cookie-secure: true

In this config if I set the callback-uri environment variable (OAUTH_CALLBACK_URI) to /oauth/callback/azure, for example, then the full URL that seems to be used is http://xxxxx/oauth/callback/azure.例如,在此配置中,如果我将 callback-uri 环境变量 (OAUTH_CALLBACK_URI) 设置为 /oauth/callback/azure,那么似乎使用的完整 URL 是 http://xxxxx/oauth/callback/azure。 However, if I use a full URL for the environment variable, eg https://xxxxx/oauth/callback/azure then the full URL it uses still appends that as opposed to using it as an absolute URL, ie http://xxxxx/https://xxxxx/oauth/callback/azure.但是,如果我使用环境变量的完整 URL,例如 https://xxxxx/oauth/callback/azure,那么它使用的完整 URL 仍会附加该 URL,而不是将其用作绝对 URL,即 http://xxxxx /https://xxxxx/oauth/callback/azure。

Is it possible to specify this uri as an absolute one and not have it append it like the above effectively duplicating it?是否可以将这个 uri 指定为绝对的,而不是像上面那样有效地复制它?

Good news.好消息。 This was fixed in micronaut-security 2.3.4 https://github.com/micronaut-projects/micronaut-security/pull/644这已在 micronaut-security 2.3.4 https://github.com/micronaut-projects/micronaut-security/pull/644中修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM