带有 JWT 的 AAD:从 URL 中隐藏 Id_Token [英] AAD with JWT: Hide Id_Token from URL

查看:38
本文介绍了带有 JWT 的 AAD:从 URL 中隐藏 Id_Token的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AAD 请求令牌.我在 Azure 中重定向到 https://localhost:44313/index.html,但是,当登录并重定向,令牌写在我的 URL 上,如下所示:https://localhost:44313/index.html#!#id_token=eyJ0eXAiOiJKV1QiLCJh...

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...

我正在使用 ADAL,如果我打印 {{userInfo}},它不会打印任何内容,但是,如果我删除 #!从 url,它有一个正确的动作,我的 url 变成:https://localhost:44313/index.html 并按原样打印 {{userInfo}}.

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.

为什么会发生这种情况,我应该怎么做才能避免 url 上的令牌?我是否应该采取一些措施来手动删除 #!来自网址?

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

这是 Azure 上的本机应用程序,使用 Angular 和 HTML.

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

谢谢大家

推荐答案

启用 Html5Mode 时,页面上的链接被替换为带有事件侦听器的 Angular.当这些事件被触发时,当前页面被推送到浏览器历史记录中,新页面是加载.这给人一种你正在导航到一个新页面的错觉,甚至允许后退按钮操作.

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.

参见 AngularJS - $location html5Mode 是如何工作的?使用以下删除 !#

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 });
    });

在您在 Azure 上选择的重定向页面上,在本例中,https://localhost:44313/index.html,编辑 HTML 并添加以下内容:

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>

谢谢

这篇关于带有 JWT 的 AAD:从 URL 中隐藏 Id_Token的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆