2

I read all the documentation of Keyrock and Wilma and I watched all the videos in the FIWARE Academy, but I still do not get success in this integration. I am searching for this since a few days ago, but without success. I think the FIWARE documentation could have tutorials, hands on...

I have a VM with Orion Context Broker and a container with Keyrock IdM and Wilma PEP Proxy. I am trying to generate an access token to grant access for an application, but I still did not get it. Besides, I would like to know how can I securely exchange messages between the Orion Context Broker and some IoT devices. Indeed, it is complicated to think about IoT devices having to access a screen and put their credentials to authenticate and to be authorized like the Keyrock IdM examples show. What do you sugest?

4

3 回答 3

2

在这里看到@albertinisg 的答案,我找到了一个用于令牌请求的bash 脚本。我将其更改为与我的本地实例一起使用并且它有效。

在 FIWARE 门户注册我的应用程序后(更多信息在这里),我必须向http://idm:8000/oauth2/token发出 POST 请求(idm 是我的本地 Keyrock 实例)。使用这个有效的令牌,我可以访问 Orion 中的内容。

import requests, json, getpass

TOKEN_URL = "http://idm:5000/v2.0/tokens"

USER = raw_input("Username: ")
PASSWORD = getpass.getpass("Password: ")
PAYLOAD = "{\"auth\": {\"passwordCredentials\": {\"username\":\""+USER+"\", \"password\":\""+PASSWORD+"\"}}}"
HEADERS =  {'content-type': 'application/json'}
RESP = requests.post(TOKEN_URL, data=PAYLOAD, headers=HEADERS)

PEP 代理 (Wilma) 配置 (config.js):

config.app_host = 'my_orion_ip'; //change to your Orion address
config.app_port = '1026'; //change to your Orion port

config.username = 'pep_proxy_credential_obtained_at_portal';
config.password = 'password_obtained_at_portal';

使用有效的令牌和运行此配置的 PEP 代理 (Wilma) 服务器,可以控制对 Orion 的访问,对 PEP 代理地址进行请求。PEP 代理将此请求重定向到 IdM (Keyrock),以便 IdM 可以验证用户/设备凭据。如果凭证有效,用户/设备将收到一个有效的令牌,现在 PEP 代理可以允许访问 Orion。

对于 HTTPS 通信,我将 Nginx 服务器配置为充当反向代理(.conf 文件):

server {
   listen       443;
   server_name  orion;

   ssl                  on;
   ssl_certificate      /etc/nginx/ssl/orion.crt;
   ssl_certificate_key  /etc/nginx/ssl/orion.key;
   ...
   ...
   location / {
      #root   orion:1026;   #/var/www/yourdomain.com;
       #index  index.php index.html index.htm;
       proxy_set_header        Host $host;
       proxy_set_header        X-Real-IP $remote_addr;
       proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header        X-Forwarded-Proto $scheme;

       # Fix the “It appears that your reverse proxy set up is broken" error.
       proxy_pass          http://orion:1026;
       proxy_read_timeout  90;
       proxy_redirect      http://orion:1026 https://orion;
   }
}

我做了一个关于FIWARE Orion、Wilma和Keyrock集成的简单教程:https ://www.slideshare.net/daltoncezane/integrating-fiware-orion-keyrock-and-wilma

我希望这个答案可以帮助别人。

于 2016-12-13T20:50:07.573 回答
2

关于 Orion,它取决于要保护的接口,服务 API(即 Orion 通常在端口 1026 上运行的侦听 REST 服务器)、通知 API 或两者:

  • 关于服务API:
    • 身份验证和授权:可以通过 PEP 实现。以下文档介绍了两种 PEP 替代实现。但是,请注意 PEP 不能独立工作,因为它还需要 IDM 和访问控制才能工作。我知道@Alvaro 可以详细解释这个话题(关于 Wilma PEP)。这是我不知道的。
    • 加密:它可以由充当 HTTPS 到 HTTP 桥接器的代理(例如ngnix)或 Orion 本身使用-httpsCLI 参数(与-keyand结合使用-cert)来实现。文档的这一 部分对此进行了详细说明。
  • 关于通知 API:
    • 身份验证和授权:自定义通知的当前实现(参见NGSIv2规范中的“自定义通知”部分)允许您包含可用于身份验证的自定义 HTTP 标头(例如X-Auth-Token保护您的端点的 PEP 实例所需的标头)。请注意,目前这是以静态方式完成的,即 Orion 无法直接与 IDM/AccessControl 交互以X-Auth-Token 在到期后动态设置值等。但是,可以开发一个能够执行此操作的流程并设置正确的标题(如果您对此感兴趣,我建议您查看“如何在使用 Orion 的传出通知中添加自定义标题?”帖子)。
    • 加密:可以在Rush组件中实现中继。文档的这一 部分对此进行了详细说明。

更新:从版本 1.7.0 开始,Orion 实现了本地 HTTPS 通知(即不需要 Rush)。

于 2016-12-13T14:58:27.633 回答
0

以下演示文稿将逐步向您展示如何创建基于 FIWARE 的物联网平台并使用 PEP 代理、Keystone 和 Keypass 对其进行保护。

https://docs.google.com/presentation/d/18LaWZSK4h2wncPF6hNAwK5MToLvJesR3XLrzsqrsmrw/edit?usp=sharing

我希望这有帮助

谢谢

于 2016-12-19T14:36:00.357 回答