'az keyvault role assignment' does not check for valid OIDs
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62
The below command should validate the --assignee parameter before creating the role assignment.
**Related command**
az keyvault role assignment create --hsm-name "YourMHSM" --role 'Managed HSM Crypto User' --assignee 'application_object_id' --scope /keys/keyname
**Describe the bug**
In the above, we can specify any Application ID as assignee and the command will execute. This triggers an error when accessing the key's RBAC assignments in the portal. The portal bug is currently being investigated.
**To Reproduce**
1. Create a MHSM and a key.
2. In az cli, assign a role on the key (with scope /keys/keyname), and pick an application id instead.
3. In the portal, opening the above key RBAC details will trigger an error preventing the user from managing the key's RBAC.
**Expected behavior**
The command should not create a role assignment if given an invalid OID.
Following the docs, Application IDs should not be allowed: [Managed HSM role management
](https://learn.microsoft.com/en-us/azure/key-vault/managed-hsm/role-management)
"_To allow a security principal (such as **a user, a service principal, group or a managed identity**) to perform managed HSM data plane operations, they must be assigned a role that permits performing those operations._"
**Additional context**

Contributor guide
Assessment
This issue has not been assessed yet.