Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

UsersResource.search briefRepresentation started to return user attributes #46296

@lrozenblyum

Description

@lrozenblyum

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

admin/api

Describe the bug

The method org.keycloak.admin.client.resource.UsersResource.search(String, String, String, String, Boolean, String, String, Integer, Integer, Boolean, Boolean) parameter briefRepresentation = true started to return user attributes

(Javadoc says Note that it means that namely user attributes, required actions, and not before are not returned).

Version

26.5.3

Regression

  • The issue is a regression

Expected behavior

As Javadoc of the method mentions: Note that it means that namely user attributes, required actions, and not before are not returned

Actual behavior

User attributes are returned now when briefRepresentation is true

How to Reproduce?

@Test
void searchWithBriefRepresentationMustNotReturnAttributes() {
	RealmResource realmResource = getRealmResource();

	String firstName = "f";
	String lastName = "s";
	String attributeName = "a";
	String attributeValue = "b";
	String username = "any";
	UserRepresentation userRepresentation = new UserRepresentation();
	userRepresentation.setFirstName(firstName);
	userRepresentation.setLastName(lastName);
	userRepresentation.setUsername(username);
	userRepresentation.setAttributes(Map.of(attributeName, List.of(attributeValue)));
	realmResource.users().create(userRepresentation);

	List<UserRepresentation> searchResult = realmResource.users().search(
		username, null, null, null, null, null, null, null, null, null, true
	);
	assertThat(searchResult, hasSize(1));
	assertThat(searchResult.get(0).getUsername(), equalTo(username));
	// fails in Keycloak 26.5.3, used to work in 26.2.5
	assertNull(searchResult.get(0).getAttributes());
}

Anything else?

It worked in Keycloak 26.2.5

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions