【问题标题】:Why XACML Response Returns NotApplicable on Azure Web App?为什么 XACML 响应在 Azure Web App 上返回 NotApplicable?
【发布时间】:2019-01-23 12:07:16
【问题描述】:

首先,我在 [blog]:https://www.javadevjournal.com/spring-boot/spring-boot-application-intellij/ 上基于 IntelliJ 创建了一个 Spring Boot 项目。然后,我在其中生成了一个带有 @PostMapping 的控制器和服务。我使用 balana [github]:https://github.com/wso2/balana 来实现 XACML 引擎。

当[博客]:https://docs.wso2.com/display/IS570/Writing+XACML+3+Policies+in+WSO2+Identity+Server+-+7 被遵循时,策略和 xacml 请求被创建为硬编码。当通过 Postman 作为 http post (http://localhost:8080/evaluate) 调用该服务时,xacml 响应在 PERMIT 和 DENY 决定下正常工作。到这里一切正常。

当我想将它发布到 azure web 应用程序时,响应包括 NotApplicable 作为决定。我的政策和要求是否有任何异常或我遗漏了什么?

示例政策

<Policy xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" PolicyId="2" RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" Version="1.0">
    <Description>sample policy</Description>
    <Target></Target>
    <Rule Effect="Permit" RuleId="primary-group-customer-rule">
        <Target>
            <AnyOf>
                <AllOf>
                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-regexp-match">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">http://localhost:8280/services/echo/</AttributeValue>
                        <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true">                 </AttributeDesignator>
                    </Match>
                    <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
                        <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
                        <AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
                    </Match>
                </AllOf>
            </AnyOf>
        </Target>
        <Condition>
            <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-subset">
                <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag">
                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">admin</AttributeValue>
                </Apply>
                <AttributeDesignator AttributeId="group" Category="urn:oasis:names:tc:xacml:3.0:group" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true"></AttributeDesignator>
            </Apply>
        </Condition>
    </Rule>
    <Rule Effect="Deny" RuleId="deny-rule"></Rule>
</Policy>

XACML 请求示例

<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
    <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action">
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">read</AttributeValue>
        </Attribute>
    </Attributes>
    <Attributes Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject">
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">admin</AttributeValue>
        </Attribute>
    </Attributes>
    <Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
        <Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">http://localhost:8280/services/echo/</AttributeValue>
        </Attribute>
    </Attributes>
    <Attributes Category="urn:oasis:names:tc:xacml:3.0:group">
        <Attribute AttributeId="group" IncludeInResult="false">
            <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">admin</AttributeValue>
        </Attribute>
    </Attributes>
</Request>

本地主机响应


<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
  <Result>
    <Decision>Permit</Decision>
    <Status><StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/></Status>
  </Result>
</Response>

Azure Web App 上的响应


<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17">
  <Result>
    <Decision>NotApplicable</Decision>
    <Status><StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/></Status>
  </Result>
</Response>

【问题讨论】:

    标签: azure spring-boot azure-web-app-service xacml xacml3


    【解决方案1】:

    根据您的应用程序的部署位置,在决策(许可或拒绝)方面应该没有区别。

    我可以告诉您如何确定问题是出在您的申请、您的政策还是您的请求中的错误。

    首先,为了验证请求是否相同,您是否检查过 Azure 和本地主机上的 PDP 日志以确保请求确实是相同的?

    如果是这样,接下来我建议您设置一个非常非常简单的规则,无论如何都会返回 DENY。然后确保在本地运行 Spring Boot 应用程序(即计算机上的$ mvn spring-boot:run)和部署的服务器上获得拒绝。

    如果您无法在两者上都获得 DENY,则需要重新访问您的应用程序逻辑等。

    一旦您收到拒绝,请设置一个采用一个参数的简单策略。 IE。如果 someNumber == 2,则返回 PERMIT。然后在您的本地主机和 Azure 上尝试此操作。一旦你有了这个工作,你就可以尝试你在问题中提到的政策。

    仅供参考,我有多个 Spring Boot 项目与我的 Github 中的 XACML 引擎(Axiomatics,而不是 WSO2)进行通信,例如:https://github.com/michaelcgood/Axiomatics-Yet-Another-PEP

    我的网站上还有多篇关于 Spring Boot 的文章:https://michaelcgood.com/category/spring/。如果您对内容或代码有任何疑问,可以联系我(联系页面上的信息),我会尽可能回复。

    【讨论】:

    • 感谢您的回复。在审查您的存储库后,除非我能解决,否则我会与您联系。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-03
    • 1970-01-01
    • 1970-01-01
    • 2018-07-25
    • 2019-07-24
    • 2018-10-23
    • 1970-01-01
    相关资源
    最近更新 更多