问题描述
Azure服务主体默认具有到期日期,并且需要轮换。
但是有没有办法使服务主体无效或强制到期?
解决方法
服务主体进行身份验证时使用的凭据可以存储在服务主体本身上,也可以存储在支持应用程序的对象上(即“应用程序注册”)。
当前不支持更改现有凭证的到期日期。如果要禁用凭据,则应将其删除。 (如果您希望重新启用它,则只需将其重新添加为授权证书即可。)
从应用程序中删除凭据(应用程序注册)
使用Azure门户
使用Azure AD PowerShell
致remove a key credential(证书):
Remove-AzureADApplicationKeyCredential -ObjectId "{id}" -KeyId "{key-id}"
致remove a password credential(客户端密钥):
Remove-AzureADApplicationPasswordCredentia -ObjectId "{id}" -KeyId "{key-id}"
使用Microsoft Graph
致remove a key credential(证书):
POST https://graph.microsoft.com/v1.0/applications/{id}/removePassword
Content-type: application/json
{
"keyId": "{key-id}"
}
致remove a password credential(客户密码):
POST https://graph.microsoft.com/v1.0/applications/{id}/removePassword
Content-type: application/json
{
"keyId": "{key-id}"
}
从服务主体中删除凭据
使用Azure门户
当前无法使用Azure门户来管理直接存储在服务主体上的凭据。
使用Azure AD PowerShell
致remove a key credential(证书):
Remove-AzureADServicePrincipalKeyCredential -ObjectId "{id}" -KeyId "{key-id}"
致remove a password credential(客户端密钥):
Remove-AzureADMSApplicationPassword -ObjectId "{id}" -KeyId "{key-id}"
使用Microsoft Graph
致remove a key credential(证书):
POST https://graph.microsoft.com/v1.0/servicePrincipals/{id}/removeKey
Content-type: application/json
{
"keyId": "{key-id}"
}
致remove a password credential(客户端密钥):
POST https://graph.microsoft.com/v1.0/servicePrincipals/{id}/removePassword
Content-type: application/json
{
"keyId": "{key-id}"
}