ADAL,Angular 6 - 返回 url 参数

ADAL, Angular 6 - returning url parameters

我已经将 ADAL 用于 angular 6 库: https://www.npmjs.com/package/microsoft-adal-angular6

从 AzureAD 返回时,将以下内容添加到 URL。这不是很用户友好,是否可以避免这些参数?

https://localhost:44355/#id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjdfWnVmMXR2a3dMeFlhSFMzcTZsVWpVWUlHdyIsImtpZCI6IjdfWnVmMXR2a3dMeFlhSFMzcTZsVWpVWUlHdyJ9.eyJhdWQiOiJiMzE0MWE1Yy1jM2Q0LTRhMTEtOTVlYS1jOThmNDQ3ODdiYWMiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9hYzZlOTdjMi1hOGIwLTQ1NTUtOTdiMy03MDAwMWE2YTc0NDgvIiwiaWF0IjoxNTM2NTczMTY1LCJuYmYiOjE1MzY1NzMxNjUsImV4cCI6MTUzNjU3NzA2NSwiYWlvIjoiQVhRQWkvOElBQUFBbm5kNmoybUI0TmJSc1RMVUM3KzFrck5uTEV4bnd3MVk3NWZ5eEtQTWlGWWZvOEpMSW9zTGtleHJmR3FJSXZ4Z2o3WUVZakM2YVRSMWplNis4MjdGTEVuU3NoM3QzMnZGSytZNFNDSFZiSXBBU2ExcmtuSEQwb3JrbDM1d1VNZG1XR2lzZEo2TW40Z3hPMHlUUmMrQm9RPT0iLCJhbXIiOlsicnNhIl0sImVtYWlsIjoidGhvbWFzZWdAbWljcm9zb2Z0LmNvbSIsImZhbWlseV9uYW1lIjoiU2VnYXRvIiwiZ2l2ZW5fbmFtZSI6InRob21hc2VnQG1pY3Jvc29mdC5jb20iLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC83MmY5ODhiZi04NmYxLTQxYWYtOTFhYi0yZDdjZDAxMWRiNDcvIiwiaXBhZGRyIjoiMTA5LjIwMi4xNTIuMzQiLCJuYW1lIjoidGhvbWFzZWdAbWljcm9zb2Z0LmNvbSBTZWdhdG8iLCJub25jZSI6ImQzYTNhMGEyLTQ0YzMtNDJiMi1hZWQ5LTBmMmMwYzVlNmU5NiIsIm9pZCI6ImNmY2EyNzllLTUzYjItNGUxYS04NDI2LTRhMWQ0OWYwMjhlMiIsInN1YiI6Ing4ODNvN1IybUlUaHNCclVTZTNvTjFnWkxuSkJDQVVTZUw4TXlDVzVKa0kiLCJ0aWQiOiJhYzZlOTdjMi1hOGIwLTQ1NTUtOTdiMy03MDAwMWE2YTc0NDgiLCJ1bmlxdWVfbmFtZSI6InRob21hc2VnQG1pY3Jvc29mdC5jb20iLCJ1dGkiOiJoSWtHU0tpLVhrdVRSOWR3bHdjUkFBIiwidmVyIjoiMS4wIn0.r128N1nhhSFIOlKnluBMh5FdFS2PEKdxG8KndMLDon19CkZh3FlYvKH6J274m17Edn1-l1wMLd5sj0D94WbgVF1GfABUTwg_dXWJso7Rl6kD6xVb-p3f5wrh8APWPVdCNYezKZ3I95jOCtFEaCaA4YdBi7c_xxx-aMBXkG9NWL0fjdikHYS1g82hwPpekxmW0zQTryxlGOfHf5g0Y-tk_Q-gOasJuqJ4voM-xUBPqRgC1TNE2sApdbl1UnKoTdEsjWOJ0SnEpjg1sK6B2JD1aOLS509TtGlszvkObBLXsYmf0eako7iw2sWEXidxQYH1ELElMnX895Og&state=5f601453-c535-40ba-adff-f7778db01a55&session_state=xx

您应该可以通过在发布者门户的操作屏幕上设置 URL 模板来执行此操作。只需包含您希望转发到后端的参数,其他参数不会。

或者,您可以使用 set-query-parameter 策略,它可以让您完全控制正在使用的参数。

Azure AD 应用程序要求将具体且绝对的 url 注册为 return/reply url,因此无法动态更改 url 路径和参数.

尝试将 navigateToLoginRequestUrl 更改为 true 在您导入库配置的 app.module.ts 中:

imports: [
...
    MsAdalAngular6Module.forRoot({
      tenant: 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx',
      clientId: 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxx',
      redirectUri: window.location.origin,
      endpoints: {
        'https://example.com/api/': 'api'
      },
      navigateToLoginRequestUrl: true, <----- Make sure this is set to 'true'
      cacheLocation: 'localStorage'
    })
...

当设置为 true 时,令牌仍会显示在 URL 中,但只会出现一小会儿。我认为不可能更改它,因为它似乎是库本身的配置。