簡體   English   中英

如何在沒有任何授權令牌的情況下將 Azure API 用於 FHIR 服務器

[英]How to use Azure API for FHIR Server without any authorization token

為 FHIR Server 的 Azure API創建了一個資源。 我可以使用像https://fhir-server-url/metadata這樣的 URL 來查看元數據信息。 正如文檔中提到的https://docs.microsoft.com/en-us/azure/healthcare-apis/access-fhir-postman-tutorial訪問其他 URL,如https://fhir-server-url/Patient ,我們需要先獲取授權令牌。 要獲取授權令牌,我們需要 ClientID,我們可以通過在 Azure Active Directory 中創建應用程序來獲取它。 但我無權訪問它。

有什么方法可以在不需要授權令牌的情況下訪問此 URL? 通過在 Azure 門戶中進行一些設置。

如果您使用第一方受眾(例如https://azurehealthcareapis ),這是為 FHIR 部署 Azure API 時的默認設置,您實際上可以使用第一方客戶端應用程序(例如 Azure CLI)來獲取令牌。 查看https://docs.microsoft.com/azure/healthcare-apis/get-healthcare-apis-access-token-cli了解詳細信息。

首先使用 Azure CLI ( https://docs.microsoft.com/cli/azure/?view=azure-cli-latest ) 登錄:

az login

獲取令牌並存儲它

token=$(az account get-access-token --resource=https://azurehealthcareapis.com | jq -r .accessToken)

使用令牌:

curl -X GET --header "Authorization: Bearer $token" https://<FHIR ACCOUNT NAME>.azurehealthcareapis.com/Patient

從 FHIR Server Doc 看來,您可以根據FhirServer:Security:Enabled配置設置打開或關閉此功能,請參閱https://github.com/microsoft/fhir-server/blob/master/docs/Authentication.md

"FhirServer" : {
"Security": {
    "Enabled":  true,
    "Authentication": {
        "Audience": "fhir-api",
        "Authority": "https://localhost:44348"
    }
}}

一種方法是在 Azure Active Directory (AAD) 中注冊您的應用程序。

您需要在 AAD 中注冊兩個應用程序才能獲取客戶端 ID 和客戶端密鑰以檢索授權令牌。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM