[Feat UI sso] store 'provider' in user metadata (#5856)

* store sso provider in user metadata

* store user metadata

* store user auth_provider in user metadata

* add "metadata" for LiteLLM_UserTable

* fix sso test
This commit is contained in:
Ishaan Jaff 2024-09-23 17:49:36 -07:00 committed by GitHub
parent 922c8ac758
commit 391b107909
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 0 deletions

View file

@ -78,6 +78,7 @@ async def test_auth_callback_new_user(mock_google_sso, mock_env_vars, prisma_cli
mock_sso_result = MagicMock()
mock_sso_result.email = "newuser@example.com"
mock_sso_result.id = unique_user_id
mock_sso_result.provider = "google"
mock_google_sso.return_value.verify_and_process = AsyncMock(
return_value=mock_sso_result
)
@ -110,6 +111,7 @@ async def test_auth_callback_new_user(mock_google_sso, mock_env_vars, prisma_cli
assert user is not None
assert user.user_email == "newuser@example.com"
assert user.user_role == LitellmUserRoles.INTERNAL_USER_VIEW_ONLY
assert user.metadata == {"auth_provider": "google"}
finally:
# Clean up: Delete the user from the database
@ -148,6 +150,7 @@ async def test_auth_callback_new_user_with_sso_default(
mock_sso_result = MagicMock()
mock_sso_result.email = "newuser@example.com"
mock_sso_result.id = unique_user_id
mock_sso_result.provider = "google"
mock_google_sso.return_value.verify_and_process = AsyncMock(
return_value=mock_sso_result
)