2017-03-31 146 views
1

我剛剛注意到,有認證服務器端或客戶端很容易地的可能性: https://docs.feathersjs.com/authentication/readme.htmlFeathersJS:服務器到服務器的身份驗證

但這些指令依賴一個JavaScript客戶端/服務器上。一般來說,我如何使用簡單的cURL請求驗證服務器端(Microservice)?沒有電子郵件,它不是一個真正的用戶(服務器到服務器),讓我們假設我有祕密密鑰。

TL; DR我怎樣才能將它轉換爲用於服務器驗證一個簡單的捲曲請求:

app.configure(authentication({ 
    token: { 
     secret: 'my-secret' 
    } 
})); 

回答

0

這取決於feathers-authentication模塊版本。在v0.7.x:

curl 'http://localhost:3030/auth/local/' -H 'Content-Type: application/json' --data-binary '{ "email": "[email protected]", "password": "secret" }' 

在1.x中:

curl 'http://localhost:3030/authentication' -H 'Content-Type: application/json' --data-binary '{ "strategy": "local", "email": "[email protected]", "password": "secret" }' 

都返回一個令牌身份驗證的用戶。

+0

沒有用戶也沒有電子郵件。服務器到服務器。只有在JS api中需要祕密(對於服務器端)在這種情況下,curl api應該是什麼? – assafey

+1

您需要創建一些認證該服務器的方式。 CURL呼叫將是您設置爲「戰略」的Passport身份驗證策略及其所需的數據。 – Daff