marcospereirampj / python-keycloak

MIT License
704 stars 297 forks source link

IndexError raised when retrieving the realm default roles. #518

Closed daekyeongp closed 5 months ago

daekyeongp commented 7 months ago

An error occurs in the get_default_realm_role_id function in lines 2241 to 2253 of the keycloak_admin.py file.

The error occurs at line 2251 if realm_role["name"] == f"default-roles-{self.connection.realm_name}" if realm_name contains an uppercase letter.

image

The reason is that keycloak creates the default role in lowercase.

Therefore, if realm contains uppercase letters, the error return default_realm_roles[0]["id"] IndexError: list index out of range occurs.

Currently, it is temporarily modified and used as if realm_role["name"] == f"default-roles-{self.connection.realm_name}".lower().