【问题标题】:Authentication and authorization of FHIR serverFHIR服务器的认证和授权
【发布时间】:2020-07-29 06:27:44
【问题描述】:

我为 fhir 设计了一项 azure 服务。我想将它与 .NET 核心 API 一起使用,并且我想控制 API 内的身份验证和授权。我还没有找到一个示例,我可以在 azure 中对 webapi 进行身份验证,而无需使用客户端 ID、客户端密码和租户 ID 提示输入用户名和密码。还有关于授权,有没有办法限制租户只能访问某些 FHIR 患者?

【问题讨论】:

  • without prompting for username and password with clientid, client secret and tenantID 是什么意思?您的意思是您不想使用所有这些来进行身份验证,还是只使用clientid, client secret and tenantID 来进行身份验证?
  • @JoyWang 我不想回答提示,我想使用任何可以通过 API 获得令牌的东西。
  • 您要使用什么客户端应用程序?机密或公共或服务客户端应用程序?
  • @JoyWang 现在,这只是我正在处理的 API,API 将在 json 中包含所有配置,用于从 azure AD 获取令牌并从 FHIR 获取数据。我会公开 API 供客户端应用程序访问。
  • @Abhijithponnapally 检查 Oauth 2.0 中的客户端凭据流,这里有来自 Microsoft 的代码示例:github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2 dec 另请阅读正确的 Azure 广告模型:简单的 Azure Ad、Azure Ad B2B 或 Azure Ad B2C .

标签: azure asp.net-core asp.net-web-api azure-active-directory hl7-fhir


【解决方案1】:

您可以使用 Azure Active Directory client credentials flow 获取令牌以访问 Azure API for FHIR。为此,您需要在 Azure AD 中register a service client。一旦你有了一个服务客户端应用程序(和一个秘密),你就可以从 Azure AD 获取一个令牌,比如:

POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token

在负载中包含以下字段:

client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
&scope=https://<myfhirservice.azurehealthcareapis.com/.default
&client_secret=abcdef1234
&grant_type=client_credentials

然后,您可以使用 Authorization: Bearer xwy... 标头字段将该令牌提供给 FHIR API。

与服务客户端应用程序关联的服务主体必须被授予对 FHIR API 的访问权限。建议您使用 Azure RBAC configuration 进行设置,但如果您使用的租户与您的 Azure 订阅关联的租户不同,则需要使用 local RBAC configuration

目前没有办法进行“细粒度”的访问控制(例如,只有某些患者)。建议您使用 API 管理服务(例如 Azure API Management 或类似服务)来实现此类逻辑。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-24
    • 1970-01-01
    • 2015-09-21
    • 1970-01-01
    • 2016-07-17
    • 2011-11-10
    • 2018-09-03
    • 2020-11-29
    相关资源
    最近更新 更多