在这里看到@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
我希望这个答案可以帮助别人。