Associate attributes when linking Roles and Permission

I am trying to create backward compatibility for the Authorization, moving away from the legacy system. I want to know what the possibilities are with KeyCloak to achieve this.

Role 1 → Permission 1
Role 2 → Permission 2

Common attributes are A1, A2, and A3.

When linking Permission 1 to Role 1, we need the capability to associate the attributes. The attribute values are a list and can vary based on the Roles.

Is this achievable with KeyCloak? If yes, please advise me on how to achieve it.

Based on my analysis, you can have attributes either at the Role or Permission level.