2015-08-27 42 views
1

我在我的機器上安裝了Orion Context Broker和pep代理。我針對的是keyRock的全局實例和AuthZforce來驗證上下文代理。任何人都可以通過PeP代理解釋Context Broker的用法嗎?

這裏是我的config.js:

var config = {}; 

config.pep_port = 1307; 

// Set this var to undefined if you don't want the server to listen on HTTPS 
config.https = { 
    enabled: false, 
    cert_file: 'cert/cert.crt', 
    key_file: 'cert/key.key', 
    port: 443 
}; 

config.account_host = 'https://account.lab.fiware.org'; 
config.keystone_host = 'cloud.lab.fiware.org'; 
config.keystone_port = 4731; 


config.app_host = 'localhost'; 
config.app_port = '1026'; 

config.username = '<my fiware lab username>'; 
config.password = '<my fiware lab pass>'; 



// in seconds 
config.chache_time = 300; 

// if enabled PEP checks permissions with AuthZForce GE. 
// only compatible with oauth2 tokens engine 
config.azf = { 
    enabled: false, 
    host: 'auth.lab.fiware.org', 
    port: 6019, 
    path: '/authzforce/domains/d698df7f-ffd4-11e4-a09d-ed06f24e1e78/pdp' 
}; 

// list of paths that will not check authentication/authorization 
// example: ['/public/*', '/static/css/'] 
config.public_paths = []; 

// options: oauth2/keystone 
config.tokens_engine = 'oauth2'; 

config.magic_key = undefined; 

module.exports = config; 

當我做node server.js 我順利拿到:

Starting PEP proxy in port 1307. Keystone authentication ... 
Success authenticating PEP proxy. Proxy Auth-token: e2189bdc1a8b4aae9280b0fd5a6ae8a0 

下面這個installation and administration guide我做了如下命令:

捲曲 - 頭「X-Auth-Token:e2189bdc1a8b4aae9280b0fd5a6ae8a0」http://localhost:1307

從那裏我得到這個消息:

[TOKEN] Checking token with IDM... 
User access-token not authorized 

我很認真地在這裏損失,不知道通過這三個中介如何訪問上下文經紀人?

誰的主人我應該問一個令牌?

我不知道我是否在問正確的問題。所有這一切的關鍵是確保對上下文代理的訪問。

編輯1

建立auth-token.sh後,我得到了以下錯誤:

<orionError> 
    <code>400</code> 
    <reasonPhrase>Bad Request</reasonPhrase> 
    <details>service not found</details> 
</orionError> 

節點server.js報道這樣的:

Starting PEP proxy in port 1307. Keystone authentication ... 
Success authenticating PEP proxy. Proxy Auth-token: b90604bc94134c1a81414e97a23196f3 


[TOKEN] Checking token with IDM... 
[ROOT] Access-token OK. Redirecting to app... 

以前的命令:sh auth-token.sh <username> <pass>給了我:

X-Auth-Token for '<my email on fiware lab>': OxFTGtMM6ckBa7FQCUmwvvhj6GQYFc 

然後我只是curl --header "X-Auth-Token:OxFTGtMM6ckBa7FQCUmwvvhj6GQYFc" http://localhost:1307哪給了我之前提到的錯誤。

回答

2

在PEP代理的啓動屏幕中顯示的令牌不是您需要在PEP代理上驗證的令牌。請看這裏的描述:Wilma pep proxy and keystone - valid access token not found

最簡單的辦法是:

這裏下載provied文件:https://raw.githubusercontent.com/Bitergia/fiware-chanchan-docker/master/images/pep-wilma/4.3.0/auth-token.sh

更換CLIENT_ID和CLIENT_SECRET你從FIWARE實驗室得到的。同時更換https://idm/oauth2/tokenhttps://account.lab.fiware.org/oauth2/token然後只需運行:

sh auth-token.sh <user-email> <password> 

腳本會顯示您的身份驗證令牌爲您所使用的用戶帳戶。在你可以運行下面的訪問獵戶座上下文經紀人:

curl --header "X-Auth-Token: <AUTH-TOKEN-DISPLAYED>" http://localhost:1307 

您現在應該收到來自獵戶座的適當反應,這應該運行,根據您的配置,在端口1026。 也請確保您已正確配置FIWARE實驗室中的重定向URL。

+0

我還有一個問題,只是更新了我的問題,請查找編輯1。請記住,我加倍檢查並且上下文代理確實在運行。 – Vrankela

2

@geissler給出的答案是正確的。關於編輯1,這不是由PEP,Authzforce或KeyRock返回的錯誤,是關於Orion Context Broker使用情況的錯誤。

curl --header "X-Auth-Token:OxFTGtMM6ckBa7FQCUmwvvhj6GQYFc" http://localhost:1307 

您沒有查詢的任何操作,這就是爲什麼您收到此錯誤。請查看Orion User and Programmers Guide瞭解如何使用Orion Context Broker。

端到端的測試,可以隨時查詢獵戶座只是做檢索版本:

curl --header "X-Auth-Token:OxFTGtMM6ckBa7FQCUmwvvhj6GQYFc" http://localhost:1307/version 

所以,如果你得到它,你會正確地訪問受保護的獵戶座。

+0

它在我查詢信息時有效,例如:'curl -header「X-Auth-Token:OxFTGtMM6ckBa7FQCUmwvvhj6GQYFc」http:// localhost:1307/v1/queryContext -s -S --header'Content-Type:application/json'--header'Accept:application/json'-d @ - | python -mjson.tool)<< EOF {...} EOF' 我剛剛還有一個問題:如果我不在物理文件夾中,我該如何執行'sh auth-token.sh '命令現在?有沒有curl或http get命令? – Vrankela

+0

這取決於您擁有腳本的位置以及執行腳本的位置。例如,我們使用docker,爲了在容器外部運行腳本,我們使用'docker exec'作爲容器,比如'docker exec -i -t auth-token.sh user0 @ test .com測試'。如果您使用的是虛擬機,您可以通過'ssh'啓動它,只需執行'ssh user @ host'sh auth-token.sh | awk'{print \ $ 1}'「' – albertinisg

+0

我的問題是爲了獲得令牌。是否有另一種方法來achevie這個或我必須使用你剛剛描述的方法使用shell腳本? 例如,我可以用java來獲取令牌嗎? – Vrankela

相關問題