带有 JWT 的 AAD:从 URL 中隐藏 Id

编程入门 行业动态 更新时间:2024-10-27 07:16:36
本文介绍了带有 JWT 的 AAD:从 URL 中隐藏 Id_Token的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 04:46:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1390241.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:AAD   JWT   Id   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!