配置 resourceServerSetting.json 檔案
1. 停止 ThingWorx 伺服器。
2. 在與 sso-settings.json 相同的目錄中建立 resourceServerSettings.json 檔案。
以下是 resourceServerSettings.json 檔案的範例結構:
{
"ResourceServerSettings": {
"accessTokenServicesSettings": {
"clientId": "See information in the table below",
"clientSecret": "See information in the table below",
"chainedGrantType": "password",
"tokenUsernameAttribute": "See information in the table below",
"tokenPublicKeyUrl": "See information in the table below",
"administratorAlias": "See information in the table below",
administratorInternalName": "Administrator",
"tokenValidationType": "local"
},
"globalScopes": "See information in the table below",
"uriScopes": [
{
"uri": "See information in the table below",
"scopes": "See information in the table below",
"method": "See information in the table below"
}
]
}
3. 請確定有依照需求來編輯每個參數的值。您的實行可能會有所不同且它取決於若干因素,例如貴組織的安全性原則,以及用於聯合的 CAS。使用下列表格中的資訊作為指引,設定不同參數的值。
4. 啟動 ThingWorx 伺服器。
ResourceServerSettings.accessTokenServicesSettings 設定
參數
描述
clientId
Azure AD 入口網站中的用戶端應用程式 Application ID
clientSecret
用戶端應用程式密碼。
chainedGrantType
保留供日後使用。
password
tokenUsernameAttribute
保留資源請求使用者名稱的宣告名稱。
預設值:“unique_name”
tokenPublicKeyUrl
Azure AD 公開金鑰端點 (用于驗證存取權杖)。
值的建構方式如下:
https://login.microsoftonline.com/<Azure AD tenant ID>/discovery/keys?appid=<Application ID of the ThingWorx Resource Provider application>
administratorAlias
在 Azure AD 中配置的管理員使用者名稱。
administratorInternalName
在 ThingWorx 中配置的管理員使用者名稱。
Administrator
tokenValidationType
存取權杖 (JWT) 的內容點。
local
ResourceServerSettings.globalScopes 設定
參數
描述
globalScopes
逗號分隔全域範圍的清單。包括存取任何資源所需的最小範圍集。如果此參數遺失或為空,會將 THINGWORX 設定為預設全域範圍。請勿將此參數留白。如果沒有專用範圍,請將 THINGWORX 設定為值。
在 ThingWorx 作為資源提供者組態的情況下,此範圍建立于將 ThingWorx 配置為資源提供者的步驟 2 中。
"globalScopes": "THINGWORX_APP1,THINGWORX_APP2"
ResourceServerSettings.uriScopes 設定
參數
描述
uri
URI 模式。將需要額外範圍的資源或資源群組定義為全域範圍。
Thingworx/Things/** - control all Things
Thingworx/Things/Thing1 – control Thing1
scopes
額外範圍的逗號分隔清單。只有獲得所有列出的範圍 (包括全域範圍) 授權的使用者才可以取得資源。
「方法」
選用。定義範圍將套用至的 URI 方法。
* 
如果未提供方法內容,會假設指定的 URI 由所有 HTTP 方法的指定範圍所保護。
可能的值是 REST 通訊協定中允許的任何方法,例如 GET 或 POST。
如果已針對 URI 定義了範圍,則必須為全域範圍及定義的 URI 範圍都授與權限,才能存取該資源。如果有多個 URI 規則適用于請求的資源,則必須對所有相關範圍授與權限,才能存取該資源。為了避免存取受限資源,請將 URIscope 新增至這些範圍不存在於授權伺服器中的 REST 端點。除了範圍保護以外,ThingWorx 還有自己的以使用者為基礎的權限,其也會套用到範圍之上。例如,如果使用者 A 請求具有正確範圍但沒有權限的資源,則請求會失敗,並顯示 403 錯誤。
範例檔案:
這是否有幫助?