-
Notifications
You must be signed in to change notification settings - Fork 557
dbeaver/cloudbeaver#4564 change db user password #4586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * 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.server.events; | ||
|
|
||
| import org.jkiss.code.NotNull; | ||
| import org.jkiss.code.Nullable; | ||
| import org.jkiss.dbeaver.model.websocket.event.WSAbstractEvent; | ||
|
|
||
| public class WSSecurityAuditEvent extends WSAbstractEvent { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need that class? I think it would be better just write logs as usual by using Log.getLog(Class.class) |
||
| public static final String TOPIC = "cb_security_audit"; | ||
| public static final String ID = "cb_security_audit_updated"; | ||
|
|
||
| public enum Kind { | ||
| /** Fires before invoking the DBeaver core password-change handler. */ | ||
| ATTEMPTED, | ||
| /** Fires after handler success and credential-store persistence. */ | ||
| SUCCEEDED, | ||
| /** Fires on handler exception or credential-store persistence failure. */ | ||
| FAILED, | ||
| /** Fires on any of the pre-invocation gate rejections. */ | ||
| GATE_REJECTED | ||
| } | ||
|
|
||
| @Nullable | ||
| private final String projectId; | ||
| @Nullable | ||
| private final String connectionId; | ||
| @Nullable | ||
| private final String driverId; | ||
| @NotNull | ||
| private final Kind kind; | ||
| @Nullable | ||
| private final String reasonCode; | ||
| @Nullable | ||
| private final String errorClass; | ||
|
|
||
| public WSSecurityAuditEvent( | ||
| @Nullable String sessionId, | ||
| @Nullable String userId, | ||
| @Nullable String projectId, | ||
| @Nullable String connectionId, | ||
| @Nullable String driverId, | ||
| @NotNull Kind kind, | ||
| @Nullable String reasonCode, | ||
| @Nullable String errorClass | ||
| ) { | ||
| super(ID, TOPIC, sessionId, userId); | ||
| this.projectId = projectId; | ||
| this.connectionId = connectionId; | ||
| this.driverId = driverId; | ||
| this.kind = kind; | ||
| this.reasonCode = reasonCode; | ||
| this.errorClass = errorClass; | ||
| } | ||
|
|
||
| @Nullable | ||
| public String getProjectId() { | ||
| return projectId; | ||
| } | ||
|
|
||
| @Nullable | ||
| public String getConnectionId() { | ||
| return connectionId; | ||
| } | ||
|
|
||
| @Nullable | ||
| public String getDriverId() { | ||
| return driverId; | ||
| } | ||
|
|
||
| @NotNull | ||
| public Kind getKind() { | ||
| return kind; | ||
| } | ||
|
|
||
| @Nullable | ||
| public String getReasonCode() { | ||
| return reasonCode; | ||
| } | ||
|
|
||
| @Nullable | ||
| public String getErrorClass() { | ||
| return errorClass; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * 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.server.events; | ||
|
|
||
| import org.jkiss.code.NotNull; | ||
| import org.jkiss.dbeaver.Log; | ||
| import org.jkiss.dbeaver.model.websocket.WSEventHandler; | ||
|
|
||
| public class WSSecurityAuditEventHandler implements WSEventHandler<WSSecurityAuditEvent> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think that we need it. |
||
| private static final Log auditLog = Log.getLog(WSSecurityAuditEventHandler.class); | ||
|
|
||
| @Override | ||
| public void handleEvent(@NotNull WSSecurityAuditEvent event) { | ||
| auditLog.info(String.format( | ||
| "topic=%s id=%s kind=%s reasonCode=%s userId=%s sessionId=%s " | ||
| + "projectId=%s connectionId=%s driverId=%s errorClass=%s timestamp=%d", | ||
| event.getTopicId(), | ||
| event.getId(), | ||
| event.getKind(), | ||
| event.getReasonCode(), | ||
| event.getUserId(), | ||
| event.getSessionId(), | ||
| event.getProjectId(), | ||
| event.getConnectionId(), | ||
| event.getDriverId(), | ||
| event.getErrorClass(), | ||
| event.getTimestamp() | ||
| )); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,6 +170,15 @@ WebConnectionInfo testConnection( | |
| @NotNull Map<String, Object> connectionConfig | ||
| ) throws DBWebException; | ||
|
|
||
| @WebProjectAction(requireProjectPermissions = {RMConstants.PERMISSION_PROJECT_DATASOURCES_EDIT}) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it does contradict the issue. I started implementing the shape and realized that it doesn't make sense to have a per-team pw-reset block if the user can just proceed to change their password through an SQL prompt. Reasons to block PW-Resets are for shared-connections which use service accounts (when the user doesn't have edit permission on the connection object), or when an external authentication mechanism like RADIUS or OIDC are in-use. If the user has permission to run statements, they usually have permission to change their passwords on the DB technologies known to me. The only narrow use-case in which this change would expose an undesired credential change is, if the database was set up with I did generally not treat the issue as a hard policy or contract and deviated for these reasons. But I can change it, if that's desired. |
||
| boolean changeConnectionUserPassword( | ||
| @NotNull WebSession webSession, | ||
| @Nullable @WebObjectId String projectId, | ||
| @NotNull String connectionId, | ||
| @WebParameterSecure @NotNull String oldPassword, | ||
| @WebParameterSecure @NotNull String newPassword | ||
| ) throws DBWebException; | ||
|
|
||
| @WebProjectAction(requireProjectPermissions = {RMConstants.PERMISSION_PROJECT_DATASOURCES_EDIT}) | ||
| WebNetworkEndpointInfo testNetworkHandler( | ||
| @NotNull WebSession webSession, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we need to add the configuration parameter to
config/template/cloudbeaver-base.conf