Skip to content

Commit

Permalink
Merge branch 'gh-4594-perms-bugs-and-enhancements_7.6' of github.com:…
Browse files Browse the repository at this point in the history
…gchq/stroom into gh-4594_permission_inheritance
  • Loading branch information
stroomdev66 committed Nov 15, 2024
2 parents ba667ca + faa1736 commit 98aced7
Show file tree
Hide file tree
Showing 34 changed files with 1,041 additions and 276 deletions.
8 changes: 2 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ ext.versions = [
aws : '2.20.157',
bnd : '7.0.0',
curator : '4.2.0', // Curator 4 works with ZK 3.4.x in soft compatibility mode, i.e. you must exlude its dep on ZK and explicitly add one for 3.4.x
dropwizard : '4.0.10', // used to set the dropwizard-bom version, that controls lots of dependency versions
dropwizard : '4.0.4', // used to set the dropwizard-bom version, that controls lots of dependency versions
elasticsearch : '8.11.2',
httpcore : '4.4.16', // Transient dependency of Elasticsearch
flyway : '10.0.0',
Expand Down Expand Up @@ -231,7 +231,6 @@ ext.libs = [
jackson_core : "com.fasterxml.jackson.core:jackson-core", // version controlled by dropwizard-dependencies
jackson_databind : "com.fasterxml.jackson.core:jackson-databind", // version controlled by dropwizard-dependencies // files('libs/jackson-databind-2.10.5.1.jar'),//
jackson_dataformat_yaml : "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml", // version controlled by dropwizard-dependencies
jackson_datatype_jdk8 : "com.fasterxml.jackson.datatype:jackson-datatype-jdk8", // version controlled by dropwizard-dependencies
jackson_datatype_jsr310 : "com.fasterxml.jackson.datatype:jackson-datatype-jsr310", // version controlled by dropwizard-dependencies
jakarta_activation : "jakarta.activation:jakarta.activation-api", // version controlled by dropwizard-dependencies
jakarta_annotation_api : "jakarta.annotation:jakarta.annotation-api", // version controlled by dropwizard-dependencies
Expand Down Expand Up @@ -282,10 +281,7 @@ ext.libs = [
// Potentially caused by https://github.com/jnr/jffi/issues/138 and fixable with a jnr-ffi uplift in lmdbjava
// lmdbjava 0.9.0 has a cursor bug though, https://github.com/lmdbjava/lmdbjava/issues/228
lmdbjava : "org.lmdbjava:lmdbjava:0.8.2",
// This is the bridge from log4j v1 to slf4j
log4j_over_slf4j : "org.slf4j:log4j-over-slf4j", // version controlled by dropwizard-dependencies
// This is the bridge from log4j v2 to slf4j
//log4j_slf4j2_impl : "org.apache.logging.log4j:log4j-slf4j2-impl:2.24.1",
logback_classic : "ch.qos.logback:logback-classic", // version controlled by dropwizard-dependencies
logback_core : "ch.qos.logback:logback-core", // version controlled by dropwizard-dependencies
mbknor_jackson_jsonSchema : "com.kjetland:mbknor-jackson-jsonschema_2.12:1.0.36",
Expand All @@ -307,7 +303,7 @@ ext.libs = [
simple_java_mail : "org.simplejavamail:simple-java-mail:${versions.simple_java_mail}",
simple_java_mail_batch_module : "org.simplejavamail:batch-module:${versions.simple_java_mail}",
slf4j_api : "org.slf4j:slf4j-api", // version controlled by dropwizard-dependencies
snake_yaml : "org.yaml:snakeyaml:2.3",
snake_yaml : "org.yaml:snakeyaml:2.2",
solrj : "org.apache.solr:solr-solrj:8.2.0",
sqlite : "org.xerial:sqlite-jdbc:3.43.2.2",
stax_api : "stax:stax-api:1.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ public void migrate(final Context context) throws Exception {
"""
SELECT DISTINCT(a.user_id)
FROM activity a
LEFT OUTER JOIN stroom_user su
ON (su.name = a.user_id)
WHERE su.name IS NULL;""")) {
WHERE NOT EXISTS (
SELECT NULL
FROM stroom_user su
WHERE su.name = a.user_id);""")) {
try (final ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
try {
final String user = resultSet.getString(1);
LOGGER.error(() ->
"Pre migration check failure:\n`activity.user_id` '" +
user +
"' not found in `stroom_user`");
user +
"' not found in `stroom_user`");
error = true;
} catch (final RuntimeException e) {
LOGGER.error(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ public void migrate(final Context context) throws Exception {
"""
SELECT DISTINCT(ae.create_user)
FROM annotation_entry ae
LEFT OUTER JOIN stroom_user su
ON (su.name = ae.create_user)
WHERE su.name IS NULL;""")) {
WHERE NOT EXISTS (
SELECT NULL
FROM stroom_user su
WHERE su.name = ae.create_user);""")) {
try (final ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
try {
final String user = resultSet.getString(1);
LOGGER.error(() ->
"Pre migration check failure:\n`annotation_entry.create_user` '" +
user +
"' not found in `stroom_user`");
user +
"' not found in `stroom_user`");
error = true;
} catch (final RuntimeException e) {
LOGGER.error(e.getMessage(), e);
Expand All @@ -65,18 +66,20 @@ SELECT DISTINCT(ae.create_user)
"""
SELECT DISTINCT(ae.data)
FROM annotation_entry ae
LEFT OUTER JOIN stroom_user su
ON (su.name = ae.data)
WHERE ae.type = "Assigned"
AND su.name IS NULL;""")) {
WHERE ae.data IS NOT NULL
AND ae.type = "Assigned"
AND NOT EXISTS (
SELECT NULL
FROM stroom_user su
WHERE su.uuid = ae.data);""")) {
try (final ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
try {
final String user = resultSet.getString(1);
LOGGER.error(() ->
"Pre migration check failure:\n`annotation_entry.data` for 'Assigned' " +
user +
"' not found in `stroom_user`");
user +
"' not found in `stroom_user`");
error = true;
} catch (final RuntimeException e) {
LOGGER.error(e.getMessage(), e);
Expand Down
1 change: 0 additions & 1 deletion stroom-config/stroom-config-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ dependencies {
testImplementation project(':stroom-test-common')

testImplementation libs.assertj_core
testImplementation libs.jackson_datatype_jdk8
testImplementation libs.junit_jupiter_api
testImplementation libs.mbknor_jackson_jsonSchema
testImplementation libs.java_diff_utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public interface QuickFilterPageView extends View, Focus, HasUiHandlers<QuickFil
void registerPopupTextProvider(Supplier<SafeHtml> popupTextSupplier);

void setDataView(View view);

void setQuickFilterText(String quickFilterText);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.ViewWithUiHandlers;

import java.util.Objects;
import java.util.function.Supplier;

public class QuickFilterPageViewImpl extends ViewWithUiHandlers<QuickFilterUiHandlers>
Expand Down Expand Up @@ -70,16 +71,30 @@ public void setDataView(View view) {
data.setWidget(view.asWidget());
}

@Override
public void setQuickFilterText(final String quickFilterText) {
final String currVal = quickFilter.getText();
quickFilter.setText(quickFilterText);
if (!Objects.equals(currVal, quickFilterText)) {
getUiHandlers().onFilterChange(quickFilterText);
}
}

@UiHandler("quickFilter")
void onFilterChange(final ValueChangeEvent<String> event) {
getUiHandlers().onFilterChange(quickFilter.getText());
}


@Override
public Widget asWidget() {
return widget;
}


// --------------------------------------------------------------------------------


public interface Binder extends UiBinder<Widget, QuickFilterPageViewImpl> {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import stroom.core.client.presenter.MonitoringPlugin;
import stroom.menubar.client.event.BeforeRevealMenubarEvent;
import stroom.security.client.api.ClientSecurityContext;
import stroom.security.client.event.OpenAppPermissionsEvent;
import stroom.security.client.presenter.AppPermissionsPresenter;
import stroom.security.shared.AppPermission;
import stroom.security.shared.UserFields;
import stroom.svg.shared.SvgImage;
import stroom.widget.menu.client.presenter.IconMenuItem.Builder;
import stroom.widget.util.client.KeyBinding.Action;
Expand All @@ -21,12 +23,23 @@
@Singleton
public class AppPermissionsPlugin extends MonitoringPlugin<AppPermissionsPresenter> {

public static final String SCREEN_NAME = "Application Permissions";

@Inject
public AppPermissionsPlugin(final EventBus eventBus,
final ContentManager contentManager,
final Provider<AppPermissionsPresenter> presenterProvider,
final ClientSecurityContext securityContext) {
super(eventBus, contentManager, presenterProvider, securityContext);

registerHandler(getEventBus().addHandler(OpenAppPermissionsEvent.getType(), event -> {
open(appPermissionsPresenter ->
appPermissionsPresenter.setFilterInput(buildFilterInput(event.getSubjectId())));
}));
}

private String buildFilterInput(final String subjectId) {
return UserFields.FIELD_DISPLAY_NAME + ":" + subjectId;
}

@Override
Expand All @@ -37,7 +50,7 @@ protected void addChildItems(final BeforeRevealMenubarEvent event) {
new Builder()
.priority(20)
.icon(SvgImage.SHIELD)
.text("Application Permissions")
.text(SCREEN_NAME)
.action(getOpenAction())
.command(this::open)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import stroom.core.client.presenter.MonitoringPlugin;
import stroom.menubar.client.event.BeforeRevealMenubarEvent;
import stroom.security.client.api.ClientSecurityContext;
import stroom.security.client.event.OpenUserOrGroupEvent;
import stroom.security.client.presenter.UserAndGroupsPresenter;
import stroom.security.shared.AppPermission;
import stroom.security.shared.UserFields;
import stroom.svg.shared.SvgImage;
import stroom.widget.menu.client.presenter.IconMenuItem.Builder;
import stroom.widget.util.client.KeyBinding.Action;
Expand All @@ -21,12 +23,23 @@
@Singleton
public class UsersAndGroupsPlugin extends MonitoringPlugin<UserAndGroupsPresenter> {

public static final String SCREEN_NAME = "Users And Groups";

@Inject
public UsersAndGroupsPlugin(final EventBus eventBus,
final ContentManager contentManager,
final Provider<UserAndGroupsPresenter> presenterProvider,
final ClientSecurityContext securityContext) {
super(eventBus, contentManager, presenterProvider, securityContext);

registerHandler(getEventBus().addHandler(OpenUserOrGroupEvent.getType(), event -> {
open(userAndGroupsPresenter ->
userAndGroupsPresenter.setFilterInput(buildFilterInput(event.getSubjectId())));
}));
}

private String buildFilterInput(final String subjectId) {
return UserFields.FIELD_DISPLAY_NAME + ":" + subjectId;
}

@Override
Expand All @@ -37,7 +50,7 @@ protected void addChildItems(final BeforeRevealMenubarEvent event) {
new Builder()
.priority(30)
.icon(SvgImage.USERS)
.text("Users And Groups")
.text(SCREEN_NAME)
.action(getOpenAction())
.command(this::open)
.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package stroom.security.client.event;

import stroom.security.client.event.OpenAppPermissionsEvent.OpenAppPermissionsHandler;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HasHandlers;

import java.util.Objects;

public class OpenAppPermissionsEvent extends GwtEvent<OpenAppPermissionsHandler> {

private static Type<OpenAppPermissionsHandler> TYPE;
private final String subjectId;

private OpenAppPermissionsEvent(final String subjectId) {
this.subjectId = Objects.requireNonNull(subjectId);
}

/**
* Open the named node on the nodes screen
*/
public static void fire(final HasHandlers handlers, final String subjectId) {
handlers.fireEvent(new OpenAppPermissionsEvent(subjectId));
}

public static Type<OpenAppPermissionsHandler> getType() {
if (TYPE == null) {
TYPE = new Type<>();
}
return TYPE;
}

@Override
public Type<OpenAppPermissionsHandler> getAssociatedType() {
return getType();
}

@Override
protected void dispatch(final OpenAppPermissionsHandler handler) {
handler.onOpen(this);
}

public String getSubjectId() {
return subjectId;
}

@Override
public String toString() {
return "OpenAppPermissionsEvent{" +
"subjectId='" + subjectId + '\'' +
'}';
}

// --------------------------------------------------------------------------------


public interface OpenAppPermissionsHandler extends EventHandler {

void onOpen(OpenAppPermissionsEvent event);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package stroom.security.client.event;

import stroom.security.client.event.OpenUserOrGroupEvent.OpenUserOrGroupHandler;
import stroom.util.shared.GwtNullSafe;
import stroom.util.shared.UserRef;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HasHandlers;

import java.util.Objects;

public class OpenUserOrGroupEvent extends GwtEvent<OpenUserOrGroupHandler> {

private static Type<OpenUserOrGroupHandler> TYPE;
private final String subjectId;

private OpenUserOrGroupEvent(final String subjectId) {
this.subjectId = Objects.requireNonNull(subjectId);
}

/**
* Open the named node on the nodes screen
*/
public static void fire(final HasHandlers handlers, final String subjectId) {
handlers.fireEvent(new OpenUserOrGroupEvent(Objects.requireNonNull(subjectId)));
}

/**
* Open the named node on the nodes screen
*/
public static void fire(final HasHandlers handlers, final UserRef userRef) {
handlers.fireEvent(new OpenUserOrGroupEvent(GwtNullSafe.requireNonNull(
userRef,
UserRef::getSubjectId,
() -> "subjectId required")));
}

public static Type<OpenUserOrGroupHandler> getType() {
if (TYPE == null) {
TYPE = new Type<>();
}
return TYPE;
}

@Override
public Type<OpenUserOrGroupHandler> getAssociatedType() {
return getType();
}

@Override
protected void dispatch(final OpenUserOrGroupHandler handler) {
handler.onOpen(this);
}

public String getSubjectId() {
return subjectId;
}

@Override
public String toString() {
return "OpenUserOrGroupEvent{" +
"subjectId='" + subjectId + '\'' +
'}';
}

// --------------------------------------------------------------------------------


public interface OpenUserOrGroupHandler extends EventHandler {

void onOpen(OpenUserOrGroupEvent event);
}
}
Loading

0 comments on commit 98aced7

Please sign in to comment.