Skip to content

Commit

Permalink
Final adjustments
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zaoral <[email protected]>
  • Loading branch information
Pepo48 committed Aug 9, 2024
1 parent c11aaa4 commit b648c35
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 10 deletions.
8 changes: 7 additions & 1 deletion js/apps/admin-ui/cypress/e2e/clients_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("Clients test", () => {
);
});

it("Should check temporary admin service existence", () => {
it("Should check temporary admin service label (non)existence", () => {
commonPage.sidebar().goToRealm("master");
commonPage.sidebar().goToClients();
commonPage
Expand All @@ -125,6 +125,12 @@ describe("Clients test", () => {
commonPage
.tableUtils()
.checkTemporaryAdminLabelExists("temporary-admin-label");

commonPage.tableToolbarUtils().searchItem("admin-cli", false);
commonPage.tableUtils().checkRowItemExists("admin-cli");
commonPage
.tableUtils()
.checkTemporaryAdminLabelExists("temporary-admin-label", false);
});

it("Should list client scopes", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ export default class TablePage extends CommonElements {
return this;
}

checkTemporaryAdminLabelExists(labelId: string) {
checkTemporaryAdminLabelExists(labelId: string, exist = true) {
cy.get(
(this.#tableInModal ? ".pf-v5-c-modal-box.pf-m-md " : "") +
this.#tableRowItem,
)
.find(`#${labelId}`)
.should("exist");
.should((!exist ? "not." : "") + "exist");
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion js/apps/admin-ui/src/Banners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const WarnBanner = (msg: string) => {
const { t } = useTranslation();

return (
<Banner screenReaderText={t(msg)} isSticky>
<Banner screenReaderText={t(msg)} variant="gold" isSticky>
<Flex spaceItems={{ default: "spaceItemsSm" }}>
<FlexItem>
<ExclamationTriangleIcon />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import org.keycloak.services.resources.admin.permissions.UserPermissionEvaluator;
import org.keycloak.utils.SearchQueryUtils;

import static org.keycloak.services.managers.ApplianceBootstrap.TEMP_ADMIN_ATTR_NAME;

public class BruteForceUsersResource {
private static final Logger logger = Logger.getLogger(BruteForceUsersResource.class);
private static final String SEARCH_ID_PARAMETER = "id:";
Expand Down Expand Up @@ -169,7 +167,6 @@ private Stream<BruteUser> toRepresentation(RealmModel realm, UserPermissionEvalu
ModelToRepresentation.toBriefRepresentation(user) :
ModelToRepresentation.toRepresentation(session, realm, user);
userRep.setAccess(usersEvaluator.getAccess(user));
ModelToRepresentation.addAttributeToBriefRep(user, userRep, TEMP_ADMIN_ATTR_NAME);
return userRep;
}).map(this::getBruteForceStatus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,7 @@ public final class Constants {

//attribute name used to mark a client as realm client
public static final String REALM_CLIENT = "realm_client";

//attribute name used to mark a temporary admin user/service account as temporary
public static final String TEMP_ADMIN_ATTR_NAME = "temporary_admin";
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.keycloak.models.light.LightweightUserAdapter.isLightweightUser;
import static org.keycloak.models.Constants.TEMP_ADMIN_ATTR_NAME;

/**
* @author <a href="mailto:[email protected]">Bill Burke</a>
Expand Down Expand Up @@ -265,6 +266,7 @@ public static UserRepresentation toBriefRepresentation(UserModel user) {
rep.setEnabled(user.isEnabled());
rep.setEmailVerified(user.isEmailVerified());
rep.setFederationLink(user.getFederationLink());
addAttributeToBriefRep(user, rep, TEMP_ADMIN_ATTR_NAME);

return rep;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.keycloak.models.RealmProvider;
import org.keycloak.models.UserModel;

import static org.keycloak.services.managers.ApplianceBootstrap.TEMP_ADMIN_ATTR_NAME;
import static org.keycloak.models.Constants.TEMP_ADMIN_ATTR_NAME;

public class TemporaryAdminAccountEventListenerProvider implements EventListenerProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.keycloak.userprofile.UserProfileProvider;
import org.keycloak.utils.StringUtil;

import static org.keycloak.models.Constants.TEMP_ADMIN_ATTR_NAME;

/**
* @author <a href="mailto:[email protected]">Bill Burke</a>
* @version $Revision: 1 $
Expand All @@ -46,7 +48,6 @@ public class ApplianceBootstrap {
public static final String DEFAULT_TEMP_ADMIN_USERNAME = "temp-admin";
public static final String DEFAULT_TEMP_ADMIN_SERVICE = "temp-admin";
public static final int DEFAULT_TEMP_ADMIN_EXPIRATION = 120;
public static final String TEMP_ADMIN_ATTR_NAME = "temporary_admin";

private final KeycloakSession session;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.keycloak.services.managers.ApplianceBootstrap.TEMP_ADMIN_ATTR_NAME;
import static org.keycloak.models.Constants.TEMP_ADMIN_ATTR_NAME;

/**
* @author <a href="mailto:[email protected]">Bill Burke</a>
Expand Down

0 comments on commit b648c35

Please sign in to comment.