chainlit icon indicating copy to clipboard operation
chainlit copied to clipboard

[Feature] Add Azure AD Group Memberships to User Metadata

Open parthbs opened this issue 10 months ago • 3 comments

This PR updates the oauth_providers.py file to include Azure Active Directory (Azure AD) group memberships in the user metadata.

The following changes were made:

  1. Fetch Group Memberships: Added logic to retrieve group memberships using the Microsoft Graph API.
  2. Error Handling: Implemented a try-except block to gracefully handle any errors during the group membership fetch process.
  3. User Metadata Update: Updated the User object to include the fetched group memberships under the groups key in the metadata.

Testing:

  • Verified that group memberships are correctly fetched and added to the user metadata.
  • Tested error handling to ensure the application continues to function if the group membership fetch fails.

Dependencies:

  • No new dependencies were added.

Notes:

  • This change ensures that user group memberships are available for downstream processes that rely on user metadata.
  • Backward compatibility is maintained as errors during group membership fetch are ignored.

parthbs avatar Mar 20 '25 19:03 parthbs

@parthbs can we put this under a Boolean parameter in @cl.login? My company has 10s of thousands of groups for some reason and this could blow up the metadata for some.

hayescode avatar Mar 21 '25 14:03 hayescode

@willydouhard can you check this PR now?

parthbs avatar Mar 25 '25 04:03 parthbs

I see that you initialise a user_data variable but I was talking about user_group

willydouhard avatar Apr 13 '25 08:04 willydouhard

@parthbs you can retrieve group memberships using the token this already retrieves. No need to force this into the framework when most users won't need this.

hayescode avatar Jul 25 '25 22:07 hayescode