code-specialist / fastapi-keycloak

Keycloak integration for Python FastAPI
https://fastapi-keycloak.code-specialist.com/
Apache License 2.0
192 stars 49 forks source link

Move the exception of missing 'realm_access section' into the model itself #62

Closed fherrera124 closed 2 years ago

fherrera124 commented 2 years ago

With this patch, if the realm_access section is missing in the access token, then:

user=idp.get_current_user(...)
print(user.roles)

will raise an exception describing the error. The current behavior is:

....
    return self.realm_access["roles"]
TypeError: 'NoneType' object is not subscriptable
....