如何从Angular 8应用程序中的浏览器获取“网络"选项卡标题部分下具有SAML响应的Form-Data详细信息? [英] How to get Form-Data details having SAML Response under header section of network tab from Browser in angular 8 application?

查看:59
本文介绍了如何从Angular 8应用程序中的浏览器获取“网络"选项卡标题部分下具有SAML响应的Form-Data详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在angular 8应用程序中进行IDP身份验证.因此我的angular应用程序首先重定向到idp服务器,然后idp服务器给我SAML响应以进行进一步授权.此SAML响应可在浏览器的网络标签中的表格数据部分中找到.我想在我的角度应用程序中获取此SAML响应以获取我的ID和电子邮件详细信息,以进一步对其进行解码并将其用于授权.所以我的问题是,如何从浏览器获取SAML响应并将其在角度应用程序中使用.请帮忙.我可以在具有数据"部分的标题标签下的浏览器的网络"标签中看到我的SAML响应.

I am trying to do IDP authentication in angular 8 application.so my angular application first redirect to idp server and then idp server gives me SAML response for further authorization.This SAML response is available in network tab of browser under form data section.I want to get this SAML response in my angular application to get my id and email details for further decoding it and using it same for authorization.so my question is, how can i get SAML response from browser and use same in angular app.Please help.I am able to see my SAML response in network tab of browser under header tab having form Data section.

推荐答案

我是通过在我的有角项目中编写一个index.jsp文件来实现这一目标的

I achieved this by writing a index.jsp file in my angular project

<%
     String uiBaseUrl = "/ngApp";
     String samlResponse = request.getParameter("SAMLResponse");
     if (samlResponse == null) {
         String error = request.getParameter("error");
         String error_description = request.getParameter("error_description");
 %>
        <script>
            let url = '<%= uiBaseUrl %>' + '/?error='+encodeURIComponent(error)+'&error_description='+encodeURIComponent(error_description);
            window.location.href = url;
        </script>
 <% } else { %>
        <script>
            redirectToUI();
            function redirectToUI() {
                const samlResponse = '<%=samlResponse%>';
                localStorage.setItem('SAMLResponse', samlResponse);
                let url = '<%= uiBaseUrl %>';
                window.location.href = url;
                /*This will navigate to ng App base route with SAMLResponse in localStorage. Write logic in base route component to read this response*/
            }
        </script>
 <% } %>

这篇关于如何从Angular 8应用程序中的浏览器获取“网络"选项卡标题部分下具有SAML响应的Form-Data详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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