【问题标题】:Get a list of all resources accessible to users in FIWARE获取 FIWARE 中用户可访问的所有资源的列表
【发布时间】:2021-06-20 08:04:07
【问题描述】:

我想采用 FIWARE 作为我们物联网平台的一部分。 除了 Orion Context Broker,我想使用 keyrock / wilma / AuthzForce 进行身份验证和授权。

通过阅读《分步说明》等文档了解到物联网平台有多个用户,可以单独控制对资源的访问。

我想显示用户在登录我们的 IoT 应用程序后可以访问的所有资源(相当于传感器)的列表。 但是,我提到了 keyrock 和 AuthzForce API,但我认为没有这样的 API。 FIWARE 中没有获取用户资源(传感器)关系列表的 API 吗?

【问题讨论】:

    标签: fiware authzforce fiware-keyrock


    【解决方案1】:

    FIWARE 未紧密绑定到单个安全堆栈。 “逐步”tutorials 使用 Keyrock 和 Wilma 作为说明性示例,但您也可以轻松使用替代身份管理器,例如 Keycloak 或 Keystone - IDM 的角色很重要。

    鉴于FIWARE Catalogue 中的每个组件都是一个微服务,它们旨在完成一项工作而不是混合关注点,因此您需要进行以下设置 - 将角色和权限保留在 IDM 中,将静态数据添加到您的实体来描述实体是什么以及谁“拥有”它们。

    基本认证

    对于每个登录用户都能够查看您的传感器的基本身份验证,这很容易:

    • IDM 拥有用户、角色和权限。
    • 设备由 IoT 代理配置 - 这会在上下文代理中创建实体。使用静态属性,例如sensor 便于查询(Device Model 建议分类:
    "static_attributes": [
        {"name": "category", "type":"Text", "value": ["sensor"]}
    ]
    

    这将使客户能够在/entities?q=category=="sensor"&type=Device 上进行查询,以获取传感器类别中的所有设备

    如果所有登录用户可以访问所有传感器,您只需在上下文代理前面放置一个 PEP 代理,该代理拒绝所有未经身份验证的请求(即那些没有承载令牌的请求)并通过那些已登录。

    基本授权

    对于登录用户能够查看他们拥有的传感器的基本授权,这有点复杂,您需要设置权限以允许角色访问:/entities?q=category=="sensor"&type=Device&owner==XXX 同时拒绝更广泛的查询,如/entities?type=device - 然后您可以在配置时向设备添加额外的静态数据:

    "static_attributes": [
        {"name": "category", "type":"Text", "value": ["sensor"]}
        {"name": "owner", "type":"Text", "value": "XXX"}
    ]
    

    高级授权

    对于高级授权,它会更加复杂,您的 Authzforce PDP 需要遵守以下规则:

    <Rule RuleId="xxxxx-xxxx-0000-0000-000000000000" Effect="Permit">
      <Description>Query Devices</Description>
      <Target>
        <AnyOf>
          <AllOf>
            <Match MatchId="urn:oasis:names:tc:xacml:3.0:function:string-equals">
              <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">/entities?q=category=="sensor"&type=Device&owner==XXX</AttributeValue>
              <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" AttributeId="urn:thales:xacml:2.0:resource:sub-resource-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
            </Match>
          </AllOf>
        </AnyOf>
        <AnyOf>
          <AllOf>
            <Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">
              <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">GET</AttributeValue>
              <AttributeDesignator Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="true" />
            </Match>
          </AllOf>
        </AnyOf>
      </Target>
      <Condition>
        <Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:any-of">
          <Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-equal" />
          <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">security-role-0000-0000-000000000000</AttributeValue>
          <AttributeDesignator Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" AttributeId="urn:oasis:names:tc:xacml:2.0:subject:role" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false" />
        </Apply>
      </Condition>
    </Rule>
    

    角色security-role-0000-0000-000000000000 的用户被允许向设备发出GET 请求,如上所述。

    使用 XACML,可以使用 urn:oasis:names:tc:xacml:1.0:function:string-regexp-matchurn:oasis:names:tc:xacml:1.0:function:string-regexp-match 之类的函数扩展规则,但您应该寻找 XACML GUI 编辑器,XACML 3.0 spec 对机器来说比对人类更容易。默认情况下,Wilma PEP 代理为 Authzforce 传递足够的信息来回答上面定义的规则,如果您想在匹配规则中添加更多子句,您需要在您的 PEP 代理中自定义 PEP-PDP comms 以确保将更多信息发送到Authzforce 允许它裁决请求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-10
      • 1970-01-01
      • 1970-01-01
      • 2020-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-19
      相关资源
      最近更新 更多