gpt4 book ai didi

azure - 为什么 XACML 响应在 Azure Web App 上返回 NotApplicable?

转载 作者:行者123 更新时间:2023-12-02 08:01:57 25 4
gpt4 key购买 nike

首先,我在[博客]上创建了一个基于IntelliJ的Spring Boot项目:https://www.javadevjournal.com/spring-boot/spring-boot-application-intellij/ 。然后,我生成了一个 Controller 和其中包含 @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 决策的异常(exception)情况工作。到这里一切都还好。

当我想将其发布到 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 应用上的响应


<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 和本地主机上的 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/ 。如果您对内容或代码有疑问,可以联系我(联系页面上的信息),我会尽力回复。

关于azure - 为什么 XACML 响应在 Azure Web App 上返回 NotApplicable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54326935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com