How to get Form-Data details having SAML Response under header section of network tab from Browser in angular 8 application?

时间秒杀一切 提交于 2021-02-05 09:31:30

问题


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.


回答1:


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>
 <% } %>


来源:https://stackoverflow.com/questions/62673094/how-to-get-form-data-details-having-saml-response-under-header-section-of-networ

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!