ADAL,Angular 6-返回网址参数

时间:2018-09-10 10:02:34

标签: angular angular6 adal.js

我已将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

1 个答案:

答案 0 :(得分:1)

尝试在导入库配置的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中,但只是一小会儿。我认为无法更改此设置,因为它似乎是库本身的配置。