This implementation is based on https://github.com/kyrcha/keycloak-mysql-user-federation#readme. For installation process follow the link. For database table creation mysql-scripts.txt can be used.
In this implelentation Keycloak user federation considers users credentials as well as its role. This role is returned to keycloak and keycloak puts it in the user's token. You Keycloak JWT should includ this property with your custom role name in the database:
"resource_access": {
"yourClientId": {
"roles": [
"admin"
]
}
}