首页 > 解决方案 > AADSTS50146:此应用程序需要使用特定于应用程序的签名密钥进行配置

问题描述

我正在创建一个 Angular 7 应用程序。我们使用 angular-oauth2-oidc 连接到 Azure AD 并进行身份验证。Azure AD 设置为 OPENID 进行身份验证。从管理 Azure AD 的团队中,我们也得到了一个密钥。因为我是新手,所以我无法弄清楚需要在哪里使用。在网上搜索也没有得到太多帮助。

当我发布此代码并打开应用程序时,它会被重定向,但在登录 micosoft 网站本身后,它会抛出以下错误

AADSTS50146:此应用程序需要使用特定于应用程序的签名密钥进行配置。

任何人都可以帮助解决这个问题。

下面是我们在 app.component.ts 中使用的代码示例

export const authConfig: AuthConfig = {
  issuer: 'https://sts.windows.net/<tanend id>/',
  redirectUri: window.location.origin + '/',
  logoutUrl: 'https://login.microsoftonline.com/<tanend id>/oauth2/logout',
  clientId: '<cliend id>',
  strictDiscoveryDocumentValidation: false,
  responseType: 'id_token',
  scope: 'openid profile email',
  waitForTokenInMsec: 2000,
  oidc: true
};

private async ConfigAuth(): Promise<void> {
    this.oauthService.configure(authConfig);
    this.oauthService.setStorage(sessionStorage);
    this.oauthService.tokenValidationHandler = new JwksValidationHandler();
    this.oauthService.requireHttps = true;

  }

  constructor(private oauthService: OAuthService) {  }

  async ngOnInit(){
    await this.ConfigAuth();

    if (!this.oauthService.getAccessToken()) {
      this.oauthService.loadDiscoveryDocument().then((doc) => {
        this.oauthService.tryLogin()
          .catch(err => {
            console.error(err);
          })
          .then(() => {
           // this.router.navigate(['/'])
            if (!this.oauthService.hasValidAccessToken()) {
              this.oauthService.initImplicitFlow()
            }
          });
      });
    }
    console.log(this.oauthService.getAccessToken());
  }

标签: angularazure-active-directoryopenidangular-oauth2-oidc

解决方案


这是通过在 AD 方面进行更改来解决的(完成的是单独的团队,没有太多细节)还借助以下链接修改了代码 https://damienbod.com/2018/01/23/using-the-dotnet-angular-带有 azure-ad-oidc-implicit-flow 的模板/


推荐阅读