使用Amazon Cognito运行JHipster微服务

使用Amazon Cognito运行JHipster微服务,jhipster,amazon-cognito,jhipster-gateway,Jhipster,Amazon Cognito,Jhipster Gateway,我按照以下指南使用Amazon Cognito设置JHipster生成的网关: 我让网关工作得很好,我能够使用Cognito登录到管理模块,但是我不能调用任何微服务。任何尝试都会遇到以下错误: java.lang.NullPointerException:在 com.test.security.oauth2.audencevalidator.validateAudienceValidator.java:26 在 com.test.security.oauth2.audencevalidator.

我按照以下指南使用Amazon Cognito设置JHipster生成的网关:

我让网关工作得很好,我能够使用Cognito登录到管理模块,但是我不能调用任何微服务。任何尝试都会遇到以下错误:

java.lang.NullPointerException:在 com.test.security.oauth2.audencevalidator.validateAudienceValidator.java:26 在 com.test.security.oauth2.audencevalidator.validateAudienceValidator.java:13 在 org.springframework.security.oauth2.core.DelegatingOAuth2TokenValidator.validateDelegatingOAuth2TokenValidator.java:67 在 org.springframework.security.oauth2.jwt.NimbusJwtDecoder.validateJwtNimbusJwtDecoder.java:165 在 org.springframework.security.oauth2.jwt.NimbusJwtDecoder.decodennimbusjwtdecoder.java:126 在 org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationProvider.authenticate

调试显示以下代码中的访问群体变量为null:

public OAuth2TokenValidatorResult validate(Jwt jwt) {
    List<String> audience = jwt.getAudience();
    if (audience.stream().anyMatch(allowedAudience::contains)) {
        return OAuth2TokenValidatorResult.success();
    } else {
        log.warn("Invalid audience: {}", audience);
        return OAuth2TokenValidatorResult.failure(error);
    }
}

有没有人能够用Amazon Cognito成功运行jHipster生成的微服务平台?任何帮助都将不胜感激。

AWS Cognito在访问令牌中不包括受众,因此必须更新验证方法


更多详细信息可在此处找到:

AWS Cognito在访问令牌中不包含访问群体,因此必须更新验证方法

更多详细信息可在此处找到:

  security:
    oauth2:
      client:
        provider:
          oidc:
            issuer-uri: https://cognito-idp.us-east-1.amazonaws.com/[secret]
        registration:
          oidc:
            client-id: [secret]
            client-secret: [secret]