1

我正在研究需要使用 AD FS 进行身份验证的角度 SPA。我使用 Spring Boot 作为后端。

this.oauthService.configure({
      redirectUri: window.location.origin + '/app/search',
      requireHttps: true,
      scope: 'openid profile email',
      responseType: 'id_token token',
      oidc: true,
      clientId: environment.adfsClientId,
      loginUrl: environment.adfsUrl + '/oauth2/authorize',
      issuer: environment.adfsUrl,
      logoutUrl:
        environment.adfsUrl +
        '/ls/?wa=wsignoutcleanup1.0&wreply=' +
        location.protocol +
        '//' +
        location.hostname +
        (location.port ? ':' + location.port : ''),
      postLogoutRedirectUri:
        location.protocol +
        '//' +
        location.hostname +
        (location.port ? ':' + location.port : ''),
    });

上面给出的是配置。我将此作为参考。

但我收到以下错误。

加载发现文档时出错 O {headers: h, status: 0, statusText: "Unknown Error", url: "https://adfs_domain/adfs/.well-known/openid-configuration", ok: false, ...} 错误: ProgressEvent {isTrusted: true, lengthComputable: false, loaded: 0, total: 0, type: "error", ...} headers: h {normalizedNames: Map(0), lazyUpdate: null, headers: Map(0)} 消息: " https://adfs_domain/adfs/.well-known/openid-configuration 的 Http 失败响应:0 未知错误" 名称:"HttpErrorResponse" ok: false 状态:0 statusText:"未知错误" url:"https:// adfs_domain/adfs/.well-known/openid-configuration"

注意:我可以从我的浏览器访问相同的 URL,https://adfs_domain/adfs/.well-known/openid-configuration。配置中的颁发者 URL 和浏览器中的响应也是相同的。

谁能帮忙?

4

1 回答 1

0

这将是一个 CORS 问题,其中 ADFS 不允许从您的 SPA 的 Web 源向发现端点发送跨域请求。

  • 如果发现端点在浏览器中工作,则 SSL 证书没有问题

  • 但是在浏览器中访问发现端点并不是跨域请求

请参阅本文档中的第 4 项。所有授权服务器都有为 SPA 客户端启用 CORS 的选项,尽管该选项在 ADFS 中似乎有点痛苦。

于 2021-04-19T12:01:06.240 回答