在另一个服务中使用其托管标识对服务调用者进行身份验证
Authenticate service caller with its Managed Identity in another service
在另一个应用程序中验证调用方(应用服务/.NET Core WebAPI 及其托管身份,而不代表登录用户)的最先进方法是什么Service/.NET Core WebAPI(也有自己的托管身份)?我想使用 Azure API 管理来隐藏调用的服务和尽可能少的密钥。
编辑:
API App Service Azure Authorization/Active 目录设置:
API 应用注册详细信息:
应用程序 registration/API App/Authentication:
隐式授权 - 仅检查 ID 令牌
支持的帐户类型 - 单租户
应用程序 registration/API App/Expose 一个 API:
当我尝试添加客户端应用程序时得到了这个(d1d
是我的 客户端应用程序服务托管 ID 的结尾):
您的 API 不需要托管身份,任何 app registration will do. Set its application id uri and use the Azure.Identity nuget package 都可以使用如下内容获得令牌:
var managedIdentityCredential = new ManagedIdentityCredential();
var scopes = new []{"{your api application id uri}/.default"}; // E.G: api://3a768fed-640b-420c-8b33-39c701c55199/.default
var accessToken = (await managedIdentityCredential.GetTokenAsync(new Azure.Core.TokenRequestContext(scopes))).Token;
在另一个应用程序中验证调用方(应用服务/.NET Core WebAPI 及其托管身份,而不代表登录用户)的最先进方法是什么Service/.NET Core WebAPI(也有自己的托管身份)?我想使用 Azure API 管理来隐藏调用的服务和尽可能少的密钥。
编辑:
API App Service Azure Authorization/Active 目录设置:
应用程序 registration/API App/Authentication:
隐式授权 - 仅检查 ID 令牌
支持的帐户类型 - 单租户
应用程序 registration/API App/Expose 一个 API:
当我尝试添加客户端应用程序时得到了这个(d1d
是我的 客户端应用程序服务托管 ID 的结尾):
您的 API 不需要托管身份,任何 app registration will do. Set its application id uri and use the Azure.Identity nuget package 都可以使用如下内容获得令牌:
var managedIdentityCredential = new ManagedIdentityCredential();
var scopes = new []{"{your api application id uri}/.default"}; // E.G: api://3a768fed-640b-420c-8b33-39c701c55199/.default
var accessToken = (await managedIdentityCredential.GetTokenAsync(new Azure.Core.TokenRequestContext(scopes))).Token;