【问题标题】:External configuration for MSAL other than Decorator除装饰器外的 MSAL 的外部配置
【发布时间】:2020-08-21 15:42:25
【问题描述】:

我对 Angular 很陌生,最近需要从事 MSAL 方面的工作。下面是我配置 MSAL 的方式。

在应用模块下导入

MsalModule.forRoot({
  auth: {
    clientId: 'myclientid', // This is your client ID
    authority: 'https://login.microsoftonline.com/tenantid', // This is your tenant ID
    redirectUri: 'http://localhost:4200'// This is your redirect URI
    //redirectUri: 'https://myapiurl.com'// This is your redirect URI
  },
  cache: {
    cacheLocation: 'localStorage',
    storeAuthStateInCookie: isIE, // Set to true for Internet Explorer 11
  },
}, {
  popUp: !isIE,
  consentScopes: [
              'user.read',
              'openid',
              'apiguid/user_impersonation',
            ], 
  unprotectedResources: [],
  protectedResourceMap: [
              [
                'https://localhost:44331/',
                ['apiguid/user_impersonation'],
              ],
              [
                'https://myapiurl.com/userimpersonation/',
                ['apiguid/user_impersonation'],
              ],
            ], 
  extraQueryParameters: {}
})

但我的问题是,由于配置是在装饰器中,我发现很难为每个属性(如 ClientID)使用动态值。

那么在 MSAL 中是否有任何方法可以将配置作为 JSON 文件或从不同的函数加载

【问题讨论】:

    标签: angular msal


    【解决方案1】:

    我有一个我认为非常好的解决方案,并且我得到了它的工作。

    分享给有同样问题的人

    How to initialize msal configurations using APP_INITIALIZER

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-09
      • 2014-01-25
      • 2014-02-14
      • 1970-01-01
      • 2021-08-17
      • 2017-04-02
      • 2017-09-02
      • 2013-03-07
      相关资源
      最近更新 更多