Skip to content

Commit f392675

Browse files
committed
Fix missing response content type and more explicit error handling
Closes keycloak#36410 Signed-off-by: Alexander Schwartz <[email protected]>
1 parent b997d05 commit f392675

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

js/apps/admin-ui/src/components/users/UserDataTable.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { emptyFormatter } from "../../util";
4343
import { useConfirmDialog } from "../confirm-dialog/ConfirmDialog";
4444
import { BruteUser, findUsers } from "../role-mapping/resource";
4545
import { UserDataTableToolbarItems } from "./UserDataTableToolbarItems";
46+
import { NetworkError } from "@keycloak/keycloak-admin-client";
4647

4748
export type UserFilter = {
4849
exact: boolean;
@@ -141,8 +142,13 @@ export function UserDataTable() {
141142
fetchRealmInfo(adminClient),
142143
adminClient.users.getProfile(),
143144
]);
144-
} catch {
145-
return [{}, {}] as [UiRealmInfo, UserProfileConfig];
145+
} catch (error) {
146+
if (error instanceof NetworkError && error?.response?.status === 403) {
147+
// "User Profile" attributes not available for Users Attribute search, when admin user does not have view- or manage-realm realm-management role
148+
return [{}, {}] as [UiRealmInfo, UserProfileConfig];
149+
} else {
150+
throw error;
151+
}
146152
}
147153
},
148154
([uiRealmInfo, profile]) => {

rest/admin-ui-ext/src/main/java/org/keycloak/admin/ui/rest/UIRealmResource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.keycloak.admin.ui.rest;
2121

22+
import jakarta.ws.rs.Produces;
2223
import org.eclipse.microprofile.openapi.annotations.Operation;
2324
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
2425
import org.eclipse.microprofile.openapi.annotations.media.Content;
@@ -81,6 +82,7 @@ public Response updateRealm(UIRealmRepresentation rep) {
8182
@Operation(summary = "Gets information about the realm, viewable by all realm admins")
8283
@APIResponse(responseCode = "200", description = "", content = {
8384
@Content(schema = @Schema(implementation = UIRealmInfo.class, type = SchemaType.OBJECT))})
85+
@Produces(MediaType.APPLICATION_JSON)
8486
public UIRealmInfo getInfo() {
8587
auth.requireAnyAdminRole();
8688

0 commit comments

Comments
 (0)