Hello,
In some of our projects we added support for deleting users after some period of inactivity (2 years). In order to do this, you need to track the time of last activity, e.g. login timestamp with a custom extension.
Then query the Keycloak database for users that have not signed-in within the a period and use the Keycloak admin api to delete the user. Using deleting a user with the keycloak api will remove the user, their attributes, and their credentials.
Cheers,
Thomas