Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

asp.net - AAD with JWT: Hide Id_Token from URL

I'm using AAD to request a token. I have a redirect in Azure to https://localhost:44313/index.html, however, when the login is made and it redirects, token is write on my URL, something like this: https://localhost:44313/index.html#!#id_token=eyJ0eXAiOiJKV1QiLCJhb...

I'm using ADAL, and if I print {{userInfo}} it prints nothing, but, if I remove #! from url, it has a correct action, my url turns to: https://localhost:44313/index.html and print {{userInfo}} as it should be.

Why this is happening, what should I do to avoid token on url? Should I have some action to remove manually #! from url?

This is a Native-Application on Azure, using Angular and HTML.

Thank you all

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When Html5Mode is enabled, the links on the page are replaced by Angular with event listeners. When these events are triggered, the current page is pushed into the browser history, and the new page is loaded. This gives the illusion that you are navigating to a new page, and even allows for the back button to operate.

see AngularJS - How does $location html5Mode work? Use following to remove !#

angular.module('app', [])

    .config(function($routeProvider, $locationProvider) {



        // use the HTML5 History API
        $locationProvider.html5Mode({ enabled: true, requireBase: true });
    });

On the redirect page that you have selected on Azure, in this case, https://localhost:44313/index.html, edit HTML and add the following:

<head> <base href="/"> </head>

Thank you


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...