File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -122,22 +122,19 @@ def get_user_roles(self, token_info: dict) -> list[str]:
122122
123123 return roles
124124
125- def get_user_organizations (self , token : str ) -> List [Dict [str , Any ]]:
125+ def get_user_organizations (self , token_info : dict ) -> List [Dict [str , Any ]]:
126126 """
127- Get the organizations a user belongs to from their token.
127+ Get the organizations a user belongs to from their token info .
128128 This assumes that organization information is stored in the token
129129 as client roles or in user attributes.
130130
131131 Args:
132- token : The user's token
132+ token_info : The decoded token information
133133
134134 Returns:
135135 List of organization information
136136 """
137137 try :
138- # Decode the token to get user info
139- token_info = self .keycloak_openid .decode_token (token )
140-
141138 # Get organization info from resource_access or attributes
142139 # This implementation depends on how organizations are represented in Keycloak
143140 # This is a simplified example - adjust based on your Keycloak configuration
Original file line number Diff line number Diff line change @@ -32,9 +32,12 @@ def post(self, request: Request) -> Response:
3232 status = status .HTTP_401_UNAUTHORIZED ,
3333 )
3434
35+ # Get token introspection data for roles and organizations
36+ token_info = keycloak_manager .keycloak_openid .introspect (keycloak_token )
37+
3538 # Get user roles and organizations from the token
36- roles = keycloak_manager .get_user_roles (keycloak_token )
37- organizations = keycloak_manager .get_user_organizations (keycloak_token )
39+ roles = keycloak_manager .get_user_roles (token_info )
40+ organizations = keycloak_manager .get_user_organizations (token_info )
3841
3942 # Sync the user information with our database
4043 user = keycloak_manager .sync_user_from_keycloak (user_info , roles , organizations )
You can’t perform that action at this time.
0 commit comments