未使用Azure AD为Angular SPA提供资源标识符

问题描述 投票:-1回答:1

我正在使用https://github.com/damienbod/dotnet-template-angular中的修改后的Visual Studio模板,通过带有Azure AD登录的Asp.Net API来构建Angular SPA。这使用Angular上的https://github.com/damienbod/angular-auth-oidc-client与Azure进行通信。

我获得了预期的Micosoft登录,但是输入我的用户登录详细信息后,它返回错误:

AADSTS500013-未提供资源标识符

我在这里的其他一些问题中看到了此错误,但使用不同的应用程序设置却未使用相同的Angular OIDC cliet。我不确定这是否是问题,还是我在Azure应用程序注册中缺少某些内容?

angular azure oidc
1个回答
0
投票

您是否已在用于验证用户身份的Azure AD中注册了您的应用程序?在那里,您将在appsettings.json节点下的clientId文件中看到必须为ASP.NET应用程序提供的应用程序ID:

  "oidc": {
    "issuer": "https://login.microsoftonline.com/common/v2.0/",
    "client_id": "d4d8dc5a-3e3b-4cf8-9ba5-eee9e27764a1",
    "scope": "openid profile email",
    "resource": "https://graph.windows.net",
    "prompt": "consent"
  }

还请确保您在Angular应用程序中包含Azure AD租户的OIDC配置,如dotnet-angular-azure-ad-oidc库的app.module.ts函数的注释loadConfig中所述。

export function loadConfig(oidcConfigService: OidcConfigService) {
  console.log('APP_INITIALIZER STARTING');
  // https://login.microsoftonline.com/damienbod.onmicrosoft.com/.well-known/openid-configuration
  // jwt keys: https://login.microsoftonline.com/common/discovery/keys
  // Azure AD does not support CORS, so you need to download the OIDC configuration, and use these from the application.
  // The jwt keys needs to be configured in the well-known-openid-configuration.json
  return () => oidcConfigService.load(`${window.location.origin}/api/config/configuration`);
  //return () => oidcConfigService.load_using_custom_stsServer('https://localhost:44347/well-known-openid-configuration.json');
}

此配置可通过https://login.microsoftonline.com/{your-tenant-name}.onmicrosoft.com/.well-known/openid-configuration访问。

© www.soinside.com 2019 - 2024. All rights reserved.