forked from phoenix/litellm-mirror
[SSO-UI] Set new sso users as internal_view role users (#5824)
* use /user/list endpoint on admin ui * sso insert user with role when user does not exist * add sso sign in test * linting fix * rename self serve doc * add doc for self serve flow * test - sso sign in default values * add test for /user/list endpoint
This commit is contained in:
parent
a9caba33ef
commit
d100b32573
10 changed files with 404 additions and 102 deletions
|
@ -215,10 +215,13 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
|
|||
const fetchProxyAdminInfo = async () => {
|
||||
if (accessToken != null) {
|
||||
const combinedList: any[] = [];
|
||||
const proxyViewers = await userGetAllUsersCall(
|
||||
const response = await userGetAllUsersCall(
|
||||
accessToken,
|
||||
"proxy_admin_viewer"
|
||||
);
|
||||
console.log("proxy admin viewer response: ", response);
|
||||
const proxyViewers: User[] = response["users"];
|
||||
console.log(`proxy viewers response: ${proxyViewers}`);
|
||||
proxyViewers.forEach((viewer: User) => {
|
||||
combinedList.push({
|
||||
user_role: viewer.user_role,
|
||||
|
@ -229,11 +232,13 @@ const AdminPanel: React.FC<AdminPanelProps> = ({
|
|||
|
||||
console.log(`proxy viewers: ${proxyViewers}`);
|
||||
|
||||
const proxyAdmins = await userGetAllUsersCall(
|
||||
const response2 = await userGetAllUsersCall(
|
||||
accessToken,
|
||||
"proxy_admin"
|
||||
);
|
||||
|
||||
const proxyAdmins: User[] = response2["users"];
|
||||
|
||||
proxyAdmins.forEach((admins: User) => {
|
||||
combinedList.push({
|
||||
user_role: admins.user_role,
|
||||
|
|
|
@ -560,24 +560,24 @@ export const userInfoCall = async (
|
|||
page_size: number | null
|
||||
) => {
|
||||
try {
|
||||
let url = proxyBaseUrl ? `${proxyBaseUrl}/user/info` : `/user/info`;
|
||||
if (userRole == "App Owner" && userID) {
|
||||
url = `${url}?user_id=${userID}`;
|
||||
let url: string;
|
||||
|
||||
if (viewAll) {
|
||||
// Use /user/list endpoint when viewAll is true
|
||||
url = proxyBaseUrl ? `${proxyBaseUrl}/user/list` : `/user/list`;
|
||||
const queryParams = new URLSearchParams();
|
||||
if (page != null) queryParams.append('page', page.toString());
|
||||
if (page_size != null) queryParams.append('page_size', page_size.toString());
|
||||
url += `?${queryParams.toString()}`;
|
||||
} else {
|
||||
// Use /user/info endpoint for individual user info
|
||||
url = proxyBaseUrl ? `${proxyBaseUrl}/user/info` : `/user/info`;
|
||||
if (userID) {
|
||||
url += `?user_id=${userID}`;
|
||||
}
|
||||
}
|
||||
if (userRole == "App User" && userID) {
|
||||
url = `${url}?user_id=${userID}`;
|
||||
}
|
||||
if (
|
||||
(userRole == "Internal User" || userRole == "Internal Viewer") &&
|
||||
userID
|
||||
) {
|
||||
url = `${url}?user_id=${userID}`;
|
||||
}
|
||||
console.log("in userInfoCall viewAll=", viewAll);
|
||||
if (viewAll && page_size && page != null && page != undefined) {
|
||||
url = `${url}?view_all=true&page=${page}&page_size=${page_size}`;
|
||||
}
|
||||
//message.info("Requesting user data");
|
||||
|
||||
console.log("Requesting user data from:", url);
|
||||
const response = await fetch(url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
@ -594,11 +594,9 @@ export const userInfoCall = async (
|
|||
|
||||
const data = await response.json();
|
||||
console.log("API Response:", data);
|
||||
//message.info("Received user data");
|
||||
return data;
|
||||
// Handle success - you might want to update some state or UI based on the created key
|
||||
} catch (error) {
|
||||
console.error("Failed to create key:", error);
|
||||
console.error("Failed to fetch user data:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
|
|||
}) => {
|
||||
const [userData, setUserData] = useState<null | any[]>(null);
|
||||
const [endUsers, setEndUsers] = useState<null | any[]>(null);
|
||||
const [currentPage, setCurrentPage] = useState(0);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [openDialogId, setOpenDialogId] = React.useState<null | number>(null);
|
||||
const [selectedItem, setSelectedItem] = useState<null | any>(null);
|
||||
const [editModalVisible, setEditModalVisible] = useState(false);
|
||||
|
@ -124,7 +124,7 @@ const ViewUserDashboard: React.FC<ViewUserDashboardProps> = ({
|
|||
defaultPageSize
|
||||
);
|
||||
console.log("user data response:", userDataResponse);
|
||||
setUserData(userDataResponse);
|
||||
setUserData(userDataResponse.users);
|
||||
|
||||
const availableUserRoles = await getPossibleUserRoles(accessToken);
|
||||
setPossibleUIRoles(availableUserRoles);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue