Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5e7159c
dbeaver/cloudbeaver#4120 support token header
HocKu7 Apr 2, 2026
a2fe997
Merge branch 'devel' into dbeaver/cloudbeaver#4120-support-token-header
HocKu7 Apr 2, 2026
e9816e5
dbeaver/cloudbeaver#4120 support token header
HocKu7 Apr 2, 2026
ecfb5fb
dbeaver/cloudbeaver#4120 support token header
HocKu7 Apr 3, 2026
2ef8546
dbeaver/cloudbeaver#4120 support token header
HocKu7 Apr 3, 2026
c3ef7e2
dbeaver/cloudbeaver#4120 support token header
HocKu7 Apr 3, 2026
178a049
dbeaver/cloudbeaver#4120 support token header
HocKu7 Apr 3, 2026
61d6af1
dbeaver/cloudbeaver#4120 support token header
HocKu7 Apr 7, 2026
f895e85
Merge branch 'devel' into dbeaver/cloudbeaver#4120-support-token-header
HocKu7 Apr 17, 2026
991c548
dbeaver/pro#4120 added tests, now session in session holder
HocKu7 Apr 17, 2026
5d33595
dbeaver/pro#4120 review fix naming
HocKu7 Apr 20, 2026
02bc848
dbeaver/pro#4120 review fixes
HocKu7 Apr 20, 2026
4861126
Merge branch 'refs/heads/devel' into dbeaver/cloudbeaver#4120-support…
HocKu7 Apr 21, 2026
3dff740
dbeaver/cloudbeaver#4120 review fixes
HocKu7 Apr 21, 2026
881ddda
Merge branch 'devel' into dbeaver/cloudbeaver#4120-support-token-header
serge-rider Apr 24, 2026
83ec357
dbeaver/cloudbeaver#4120 session type now final
HocKu7 Apr 24, 2026
cb1d13c
Merge branch 'devel' into dbeaver/cloudbeaver#4120-support-token-header
HocKu7 Apr 27, 2026
6fdf355
dbeaver/cloudbeaver#4120 remove part from ce
HocKu7 Apr 27, 2026
5c2f2ef
dbeaver/cloudbeaver#4120 remove part from ce
HocKu7 Apr 27, 2026
862ea72
Merge branch 'devel' into dbeaver/cloudbeaver#4120-support-token-header
HocKu7 Apr 29, 2026
9e32e7c
dbeaver/cloudbeaver#4120 fix header name
HocKu7 Apr 29, 2026
1dc9370
dbeaver/cloudbeaver#4120 review fix
HocKu7 Apr 30, 2026
91f1f8d
dbeaver/cloudbeaver#4120 review fix
HocKu7 Apr 30, 2026
24f075c
dbeaver/cloudbeaver#4120 fix review
HocKu7 Apr 30, 2026
fbdf2f6
Merge branch 'devel' into dbeaver/cloudbeaver#4120-support-token-header
EvgeniaBzzz May 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,18 @@ public WebSession(
@NotNull WebHttpRequestInfo requestInfo,
@NotNull ServletAuthApplication application,
@NotNull Map<String, DBWSessionHandler<WebSession>> sessionHandlers
) throws DBException {
this(Objects.requireNonNull(requestInfo.getId()), requestInfo, application, sessionHandlers);
}

public WebSession(
@NotNull String sessionId,
@NotNull WebHttpRequestInfo requestInfo,
@NotNull ServletAuthApplication application,
@NotNull Map<String, DBWSessionHandler<WebSession>> sessionHandlers
) throws DBException {
this(
Objects.requireNonNull(requestInfo.getId()),
sessionId,
CommonUtils.toString(requestInfo.getLocale()),
application,
sessionHandlers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,6 @@ public class CBConstants {
public static final String DEFAULT_CLOUD_PROJECT_NAME = "GlobalConfiguration";

public static final String SECURED_VALUE = "******";

public static final String HEADER_API_TOKEN = "X-API-Token";
Comment thread
HocKu7 marked this conversation as resolved.
Outdated
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2025 DBeaver Corp and others
* Copyright (C) 2010-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,9 +51,9 @@
private static final Log log = Log.getLog(CBSessionManager.class);

private final CBApplication<?> application;
private final Map<String, BaseWebSession> sessionMap = new HashMap<>();
protected final Map<String, SessionHolder> sessionMap = new HashMap<>();

public CBSessionManager(CBApplication<?> application) {

Check warning on line 56 in server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'CBApplication' is missing a nullability annotation. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java:56:29: warning: Reference type 'CBApplication' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)
this.application = application;
}

Expand All @@ -75,10 +75,10 @@
}

@Override
public BaseWebSession closeSession(@NotNull String sessionId, boolean sendSessionExpiredEvent) {

Check warning on line 78 in server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'BaseWebSession' is missing a nullability annotation. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java:78:12: warning: Reference type 'BaseWebSession' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)
BaseWebSession webSession;
synchronized (sessionMap) {
webSession = sessionMap.remove(sessionId);
webSession = getSessionFromHolder(sessionMap.remove(sessionId));
}
if (webSession != null) {
log.debug("> Close session '" + sessionId + "'");
Expand All @@ -93,6 +93,11 @@
return application;
}

@Nullable
protected BaseWebSession getSessionFromHolder(@Nullable SessionHolder sessionHolder) {
return sessionHolder == null ? null : sessionHolder.getSession();
}

@Deprecated
public boolean touchSession(
@NotNull HttpServletRequest request,
Expand Down Expand Up @@ -124,14 +129,14 @@
String sessionId = getSessionId(request);
WebSession webSession;
synchronized (sessionMap) {
var baseWebSession = sessionMap.get(sessionId);
var baseWebSession = getSessionFromHolder(sessionMap.get(sessionId));
if (baseWebSession == null && CBApplication.getInstance().isConfigurationMode()) {
try {
webSession = createWebSessionImpl(new WebHttpRequestInfo(request));
} catch (DBException e) {
throw new DBWebException("Failed to create web session", e);
}
sessionMap.put(sessionId, webSession);
sessionMap.put(sessionId, new SessionHolder(SessionType.WEB, webSession));
} else if (baseWebSession == null) {
try {
webSession = createWebSessionImpl(new WebHttpRequestInfo(request));
Expand All @@ -155,7 +160,7 @@

webSession.setCacheExpired(!httpSession.isNew());

sessionMap.put(sessionId, webSession);
sessionMap.put(sessionId, new SessionHolder(SessionType.WEB, webSession));
} else {
if (!(baseWebSession instanceof WebSession)) {
throw new DBWebException("Unexpected session type: " + baseWebSession.getClass().getName());
Expand Down Expand Up @@ -214,7 +219,7 @@
WebSession webSession;
synchronized (sessionMap) {
if (sessionMap.containsKey(sessionId)) {
var cachedWebSession = sessionMap.get(sessionId);
var cachedWebSession = getSessionFromHolder(sessionMap.get(sessionId));
if (!(cachedWebSession instanceof WebSession)) {
log.warn("Unexpected session type: " + cachedWebSession.getClass().getName());
return null;
Expand All @@ -231,7 +236,7 @@
webSession = createWebSessionImpl(requestInfo);
restorePreviousUserSession(webSession, oldAuthInfo);

sessionMap.put(sessionId, webSession);
sessionMap.put(sessionId, new SessionHolder(SessionType.WEB, webSession));
log.debug("Web session restored");
return webSession;
} catch (DBException e) {
Expand Down Expand Up @@ -266,6 +271,11 @@
return new WebSession(request, application, getSessionHandlers());
}

@NotNull
Comment thread
HocKu7 marked this conversation as resolved.
Outdated
protected WebSession createWebSessionImpl(@NotNull WebHttpRequestInfo request, @NotNull String sessionId) throws DBException {
return new WebSession(sessionId, request, application, getSessionHandlers());
}

@NotNull
protected Map<String, DBWSessionHandler<WebSession>> getSessionHandlers() {
return WebHandlerRegistry.getInstance().getSessionHandlers()
Expand All @@ -277,16 +287,16 @@
@Nullable
public BaseWebSession getSession(@NotNull String sessionId) {
synchronized (sessionMap) {
return sessionMap.get(sessionId);
return getSessionFromHolder(sessionMap.get(sessionId));
}
}

@Override
@Nullable
public WebSession findWebSession(HttpServletRequest request) {

Check warning on line 296 in server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'HttpServletRequest' is missing a nullability annotation. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java:296:38: warning: Reference type 'HttpServletRequest' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)
String sessionId = getSessionId(request);
synchronized (sessionMap) {
var session = sessionMap.get(sessionId);
var session = getSessionFromHolder(sessionMap.get(sessionId));
if (session instanceof WebSession) {
return (WebSession) session;
}
Expand All @@ -309,8 +319,9 @@
public void expireIdleSessions() {
List<BaseWebSession> expiredList = new ArrayList<>();
synchronized (sessionMap) {
for (Iterator<BaseWebSession> iterator = sessionMap.values().iterator(); iterator.hasNext(); ) {
var session = iterator.next();
for (Iterator<SessionHolder> iterator = sessionMap.values().iterator(); iterator.hasNext(); ) {
var sessionHolder = iterator.next();
var session = sessionHolder.getSession();
if (!session.isValid()) {
iterator.remove();
expiredList.add(session);
Expand All @@ -324,9 +335,13 @@
}

@Override
public Collection<BaseWebSession> getAllActiveSessions() {

Check warning on line 338 in server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'Collection' is missing a nullability annotation. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java:338:12: warning: Reference type 'Collection' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)
synchronized (sessionMap) {
return new ArrayList<>(sessionMap.values());
List<BaseWebSession> sessions = new ArrayList<>(sessionMap.size());
for (SessionHolder sessionHolder : sessionMap.values()) {
sessions.add(sessionHolder.getSession());
}
return sessions;
}
}

Expand All @@ -345,7 +360,7 @@
var sessionId = requestInfo.getId() != null ? requestInfo.getId()
: authPermissions.getSessionId();

var existSession = sessionMap.get(sessionId);
var existSession = getSessionFromHolder(sessionMap.get(sessionId));

if (existSession instanceof WebHeadlessSession) {
var creds = existSession.getUserContext().getActiveUserCredentials();
Expand Down Expand Up @@ -374,7 +389,7 @@
null,
authPermissions
);
sessionMap.put(sessionId, headlessSession);
sessionMap.put(sessionId, new SessionHolder(SessionType.HEADLESS, headlessSession));
return headlessSession;
}
}
Expand All @@ -394,7 +409,7 @@
var sessionId = requestInfo.getId() != null ? requestInfo.getId()
: authPermissions.getSessionId();

var existSession = sessionMap.get(sessionId);
var existSession = getSessionFromHolder(sessionMap.get(sessionId));

if (existSession instanceof WebSession webSession) {
var creds = webSession.getUserContext().getActiveUserCredentials();
Expand Down Expand Up @@ -431,7 +446,7 @@
authPermissions
);
webSession.refreshUserData();
sessionMap.put(sessionId, webSession);
sessionMap.put(sessionId, new SessionHolder(SessionType.WEB, webSession));
return webSession;
}
}
Expand All @@ -441,8 +456,8 @@
*/
public void sendSessionsStates() {
synchronized (sessionMap) {
sessionMap.values()
.parallelStream()
sessionMap.values().parallelStream()
.map(SessionHolder::getSession)
.filter(session -> {
if (session instanceof WebSession webSession) {
return webSession.isAuthorizedInSecurityManager();
Expand All @@ -467,10 +482,10 @@

public void closeUserSession(@NotNull WSAbstractEvent event) {
synchronized (sessionMap) {
for (Iterator<BaseWebSession> iterator = sessionMap.values().iterator(); iterator.hasNext(); ) {
var session = iterator.next();
if (CommonUtils.equalObjects(session.getUserContext().getUserId(),
event.getUserId())) {
for (Iterator<SessionHolder> iterator = sessionMap.values().iterator(); iterator.hasNext(); ) {
var sessionHolder = iterator.next();
var session = sessionHolder.getSession();
if (CommonUtils.equalObjects(session.getUserContext().getUserId(), event.getUserId())) {
if (session instanceof WebHeadlessSession headlessSession) {
headlessSession.addSessionEvent(event);
}
Expand All @@ -483,8 +498,9 @@

public void closeSessions(@NotNull List<String> smSessionsId) {
synchronized (sessionMap) {
for (Iterator<BaseWebSession> iterator = sessionMap.values().iterator(); iterator.hasNext(); ) {
var session = iterator.next();
for (Iterator<SessionHolder> iterator = sessionMap.values().iterator(); iterator.hasNext(); ) {
var sessionHolder = iterator.next();
var session = sessionHolder.getSession();
if (smSessionsId.contains(session.getUserContext().getSmSessionId())) {
iterator.remove();
session.close(false, true);
Expand All @@ -498,8 +514,9 @@
*/
public void closeAllSessions(@Nullable String initiatorSessionId) {
synchronized (sessionMap) {
for (Iterator<BaseWebSession> iterator = sessionMap.values().iterator(); iterator.hasNext(); ) {
var session = iterator.next();
for (Iterator<SessionHolder> iterator = sessionMap.values().iterator(); iterator.hasNext(); ) {
var sessionHolder = iterator.next();
var session = sessionHolder.getSession();
iterator.remove();
session.close(false, !WSWebUtils.isSessionIdEquals(session, initiatorSessionId));
}
Expand All @@ -509,15 +526,15 @@
/**
* Creates new web session or returns existing one.
*/
public WebSession createWebSession(WebHttpRequestInfo requestInfo) throws DBException {

Check warning on line 529 in server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'WebHttpRequestInfo' is missing a nullability annotation. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java:529:40: warning: Reference type 'WebHttpRequestInfo' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)

Check warning on line 529 in server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 Reference type 'WebSession' is missing a nullability annotation. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.server.ce/src/io/cloudbeaver/service/session/CBSessionManager.java:529:12: warning: Reference type 'WebSession' is missing a nullability annotation. (sh.adelessfox.checkstyle.checks.NullabilityAnnotationsCheck)
String id = requestInfo.getId();
synchronized (sessionMap) {
BaseWebSession baseWebSession = sessionMap.get(id);
BaseWebSession baseWebSession = getSessionFromHolder(sessionMap.get(id));
if (baseWebSession instanceof WebSession) {
return (WebSession) baseWebSession;
} else {
WebSession webSessionImpl = createWebSessionImpl(requestInfo);
sessionMap.put(id, webSessionImpl);
sessionMap.put(id, new SessionHolder(SessionType.WEB, webSessionImpl));
return webSessionImpl;
}
}
Expand All @@ -527,4 +544,10 @@
log.debug("> Expire session '" + session.getSessionId() + "'");
session.close();
}

@NotNull
Comment thread
HocKu7 marked this conversation as resolved.
Outdated
@Override
public WebSession getWebSessionByToken(@NotNull HttpServletRequest request, @NotNull String token) throws DBException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.service.session;

import io.cloudbeaver.model.session.BaseWebSession;
import org.jkiss.code.NotNull;

public class SessionHolder {
Comment thread
HocKu7 marked this conversation as resolved.
Outdated
private final SessionType sessionType;
private final BaseWebSession session;

public SessionHolder(@NotNull SessionType sessionType, @NotNull BaseWebSession session) {
this.sessionType = sessionType;
this.session = session;
}

@NotNull
public SessionType getSessionType() {
return sessionType;
}

@NotNull
public BaseWebSession getSession() {
return session;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.service.session;

public enum SessionType {
WEB,
HEADLESS,
API_TOKEN
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
* Copyright (C) 2010-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -72,4 +72,7 @@ WebHeadlessSession getHeadlessSession(
default void expireIdleSessions() {

}

@NotNull
WebSession getWebSessionByToken(@NotNull HttpServletRequest request, @NotNull String token) throws DBException;
}
Loading
Loading