如何使用白名单框架选项

时间:2017-03-22 10:35:36

标签: sapui5 whitelist x-frame-options

目前我正在保护FIORI应用程序的前端。在阅读官方文档时,我看到可以在受信任域的帧中加载FIORI应用程序。为此,我们必须实施白名单。官方文件规定必须实施以下步骤:

  1. 致电服务:

     <meta name="sap.whitelistService" content="Whitelist.js">
    
  2. 设置白名单

    jQuery.sap.addUrlWhitelist(undefined, "https://webide-ad232er4.dispatcher.hana.ondemand.com/");
    jQuery.sap.validateUrl("https://webide-ad232er4.dispatcher.hana.ondemand.com/");
    
  3. 将frameOptions设置为信任

    data-sap-ui-frameOptions="trusted"
    

    执行官方文档规定的所有这些步骤后,通过SAP Web IDE,我在一个框架中启动我的应用程序,通常可以执行所有操作。但事实并非如此,不能执行任何操作,而且白名单服务似乎无法识别我的域名。

  4. 是否有人能够提供有关如何正确实施此内容的指导?

    P.S:这是我使用的官方文档:https://help.sap.com/saphelp_uiaddon10/helpdata/en/62/d9c4d8f5ad49aa914624af9551beb7/content.htm

    修改

    的index.html

    <!DOCTYPE HTML>
    
    <html>
    <!-- Copyright (c) 2014 SAP AG, All Rights Reserved -->
    <head>
    
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="sap.whitelistService" content="ui.2sp.mm.purchorder.approve.uis2pmmpurchorderapproveExtension.Whitelist.js" />
    
    <title>Extension Project in UShell Sandbox</title>
    
    <script type="text/javascript">
    window["sap-ushell-config"] = {
        defaultRenderer : "fiorisandbox",
        services: {
            NavTargetResolution: {
             // navigation target resolution service is configured to resolve the empty location hash to the application
                config : {
                    resolveLocal : [ {
                        "linkId" : "",
                        resolveTo : {
                            additionalInformation : "SAPUI5.Component=ui.s2p.mm.purchorder.approve.uis2pmmpurchorderapproveExtension",
                            applicationType : "URL",
                            url : "./" + window.location.search // pass URL query parameters to application
                        }
                    }]
                }
            }
        }
    };
    </script>
    
    <script src="test-resources/sap/ushell/bootstrap/sandbox.js" id="sap-ushell-bootstrap"></script>
    
     <script id="sap-ui-bootstrap" 
        src="resources/sap-ui-core.js"
        data-sap-ui-libs="sap.m"
        data-sap-ui-theme="sap_bluecrystal"
        data-sap-ui-xx-bindingSyntax="complex"
        data-sap-ui-compatVersion="1.16"
        data-sap-ui-frameOptions="trusted"
        data-sap-ui-resourceroots='{"ui.s2p.mm.purchorder.approve.uis2pmmpurchorderapproveExtension": "./"}'>
    
    </script>
    
    <!-- Create the unified shell default renderer control and add it to the page -->
    <script type="text/javascript">
    sap.ui.getCore().attachInitEvent(function() {
        sap.ushell.Container.createRenderer().placeAt("content");
    });
    </script>
    </head>
    
    <!-- UI Content -->
    <body class="sapUiBody" id="content">
    </body>
    </html>
    

    Whitelist.js

    jQuery.sap.addUrlWhitelist("https", "uis2pmmpurchorderapproveextens-ad232er4.dispatcher.hana.ondemand.com/?hc_reset");
    jQuery.sap.validateUrl("uis2pmmpurchorderapproveextens-ad232er4.dispatcher.hana.ondemand.com/?hc_reset");
    

    种类问候,

    扎卡瑞亚

1 个答案:

答案 0 :(得分:-1)

我假设您的编码行是index.html的一部分? 您能否发布完整的index.html以获取完整的上下文。

还请发布您的“Whitelist.js”。 这是您的白名单服务吗?

您是否也在Security Concepts看到了文档?

在“URL白名单过滤”一章中,它提到: “jQuery.sap.addUrlWhitelist(&#34; https&#34;,&#34; sdn.sap.com&#34;); 在相应的addUrlWhitelist语句中,您使用的是“undefined”。 如果您尝试,会发生什么: “jQuery.sap.addUrlWhitelist(”https“,&#34; webide-ad232er4.dispatcher.hana.ondemand.com&#34;);”?

您还可以查看有关New Features的文档 其中提到了SAP Notes 2245332和2142551。

相关问题