mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-13 07:47:05 +08:00
CB-2793 Use per-session resource controller
This commit is contained in:
+5
-12
@@ -60,14 +60,17 @@ public abstract class BaseWebApplication extends BaseApplicationImpl implements
|
||||
|
||||
private static final Log log = Log.getLog(BaseWebApplication.class);
|
||||
|
||||
private RMController rmController;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public DBPWorkspace createWorkspace(@NotNull DBPPlatform platform, @NotNull IWorkspace eclipseWorkspace) {
|
||||
return new WebWorkspace(platform, eclipseWorkspace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RMController createResourceController(@NotNull SMCredentialsProvider credentialsProvider) {
|
||||
throw new IllegalStateException("Resource controller is not supported by " + getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Path getDefaultWorkingFolder() {
|
||||
@@ -142,16 +145,6 @@ public abstract class BaseWebApplication extends BaseApplicationImpl implements
|
||||
return new LocalSecretController("user/" + credentialsProvider.getActiveUserCredentials().getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized RMController getResourceController() {
|
||||
if (rmController == null) {
|
||||
rmController = createResourceController();
|
||||
}
|
||||
return rmController;
|
||||
}
|
||||
|
||||
protected abstract RMController createResourceController();
|
||||
|
||||
protected Map<String, Object> getServerConfigProps(Map<String, Object> configProps) {
|
||||
return JSONUtils.getObject(configProps, "server");
|
||||
}
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public interface WebApplication extends DBPApplication {
|
||||
|
||||
DBSSecretController getSecretController(@NotNull SMCredentialsProvider credentialsProvider) throws DBException;
|
||||
|
||||
RMController getResourceController();
|
||||
RMController createResourceController(@NotNull SMCredentialsProvider credentialsProvider);
|
||||
|
||||
String getServerURL();
|
||||
|
||||
|
||||
+7
-1
@@ -127,6 +127,8 @@ public class WebSession extends AbstractSessionPersistent
|
||||
private final WebUserContext userContext;
|
||||
private final List<CBEvent> sessionEvents = new ArrayList<>();
|
||||
|
||||
private RMController rmController;
|
||||
|
||||
public WebSession(
|
||||
@NotNull HttpSession httpSession,
|
||||
@NotNull WebApplication application,
|
||||
@@ -143,6 +145,7 @@ public class WebSession extends AbstractSessionPersistent
|
||||
this.sessionHandlers = sessionHandlers;
|
||||
this.userContext = new WebUserContext(application);
|
||||
this.maxSessionIdleTime = maxSessionIdleTime;
|
||||
this.rmController = application.createResourceController(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -273,7 +276,7 @@ public class WebSession extends AbstractSessionPersistent
|
||||
}
|
||||
|
||||
public synchronized RMController getRmController() {
|
||||
return userContext.getRmController();
|
||||
return rmController;
|
||||
}
|
||||
|
||||
public synchronized void refreshUserData() {
|
||||
@@ -472,6 +475,9 @@ public class WebSession extends AbstractSessionPersistent
|
||||
addSessionError(e);
|
||||
log.error("Error reading session permissions", e);
|
||||
}
|
||||
|
||||
// Initialize new resource controller
|
||||
this.rmController = application.createResourceController(this);
|
||||
}
|
||||
|
||||
private synchronized void refreshAccessibleConnectionIds() {
|
||||
|
||||
-5
@@ -28,7 +28,6 @@ import org.jkiss.dbeaver.model.auth.SMAuthStatus;
|
||||
import org.jkiss.dbeaver.model.auth.SMCredentials;
|
||||
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
|
||||
import org.jkiss.dbeaver.model.exec.DBCException;
|
||||
import org.jkiss.dbeaver.model.rm.RMController;
|
||||
import org.jkiss.dbeaver.model.security.SMAdminController;
|
||||
import org.jkiss.dbeaver.model.security.SMController;
|
||||
import org.jkiss.utils.CommonUtils;
|
||||
@@ -155,10 +154,6 @@ public class WebUserContext implements SMCredentialsProvider {
|
||||
return adminSecurityController;
|
||||
}
|
||||
|
||||
public synchronized RMController getRmController() {
|
||||
return application.getResourceController();
|
||||
}
|
||||
|
||||
public synchronized Set<String> getUserPermissions() {
|
||||
return userPermissions;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import io.cloudbeaver.model.app.WebAuthApplication;
|
||||
import io.cloudbeaver.model.app.WebAuthConfiguration;
|
||||
import io.cloudbeaver.model.rm.local.LocalResourceController;
|
||||
import io.cloudbeaver.model.session.WebAuthInfo;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.registry.WebDriverRegistry;
|
||||
import io.cloudbeaver.registry.WebServiceRegistry;
|
||||
import io.cloudbeaver.server.jetty.CBJettyServer;
|
||||
@@ -131,13 +130,8 @@ public class CBApplication extends BaseWebApplication implements WebAuthApplicat
|
||||
protected final CBEventController eventController = new CBEventController();
|
||||
|
||||
private WebSessionManager sessionManager;
|
||||
protected final SMCredentialsProvider webSessionCredentialsProvider;
|
||||
|
||||
public CBApplication() {
|
||||
webSessionCredentialsProvider = () -> {
|
||||
WebSession activeWebSession = getSessionManager().getActiveWebSession();
|
||||
return activeWebSession == null ? null : activeWebSession.getActiveUserCredentials();
|
||||
};
|
||||
}
|
||||
|
||||
public String getServerURL() {
|
||||
@@ -516,8 +510,8 @@ public class CBApplication extends BaseWebApplication implements WebAuthApplicat
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RMController createResourceController() {
|
||||
return LocalResourceController.builder(webSessionCredentialsProvider, this::getSecurityController).build();
|
||||
public RMController createResourceController(@NotNull SMCredentialsProvider credentialsProvider) {
|
||||
return LocalResourceController.builder(credentialsProvider, this::getSecurityController).build();
|
||||
}
|
||||
|
||||
private void parseConfiguration(File configFile) throws DBException {
|
||||
|
||||
Reference in New Issue
Block a user