Skip to content

Commit

Permalink
CB-5807. Refactor after review
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisSinelnikov committed Dec 16, 2024
1 parent 0e41be4 commit 33ba65b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ WebLogoutInfo authLogout(
WebUserInfo activeUser(@NotNull WebSession webSession) throws DBWebException;

@WebAction(authRequired = false)
WebAuthProviderInfo[] getAuthProviders();
WebAuthProviderInfo[] getAuthProviders(WebSession webSession);

@WebAction()
boolean changeLocalPassword(@NotNull WebSession webSession, @NotNull String oldPassword, @NotNull String newPassword) throws DBWebException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void bindWiring(DBWBindingContext model) throws DBWebException {
CommonUtils.toBoolean(env.getArgument("linkUser"))
))
.dataFetcher("activeUser", env -> getService(env).activeUser(getWebSession(env, false)))
.dataFetcher("authProviders", env -> getService(env).getAuthProviders())
.dataFetcher("authProviders", env -> getService(env).getAuthProviders(getWebSession(env)))
.dataFetcher("authChangeLocalPassword", env -> getService(env).changeLocalPassword(
getWebSession(env),
env.getArgument("oldPassword"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ public WebUserInfo activeUser(@NotNull WebSession webSession) throws DBWebExcept
}

@Override
public WebAuthProviderInfo[] getAuthProviders() {
public WebAuthProviderInfo[] getAuthProviders(WebSession webSession) {
return WebAuthProviderRegistry.getInstance().getAuthProviders()
.stream().map(WebAuthProviderInfo::new)
.stream().map(p -> new WebAuthProviderInfo(webSession, p))
.toArray(WebAuthProviderInfo[]::new);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 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.auth.model.user;

import io.cloudbeaver.model.WebPropertyInfo;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.registry.WebAuthProviderDescriptor;
import org.jkiss.dbeaver.model.security.SMAuthCredentialsProfile;

import java.util.List;

public class WebAuthCredentialsProfileInfo {
private final SMAuthCredentialsProfile profile;
private final WebSession webSession;

public WebAuthCredentialsProfileInfo(WebSession webSession, SMAuthCredentialsProfile profile) {
this.profile = profile;
this.webSession = webSession;
}

public String getId() {
return profile.getId();
}

public String getLabel() {
return profile.getLabel();
}

public String getDescription() {
return profile.getDescription();
}

public List<WebPropertyInfo> getCredentialParameters() {
return profile.getCredentialParameters().stream().map(p -> new WebPropertyInfo(webSession, p)).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.cloudbeaver.auth.SMAuthProviderFederated;
import io.cloudbeaver.auth.provisioning.SMProvisioner;
import io.cloudbeaver.model.app.ServletAuthConfiguration;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.registry.WebAuthProviderConfiguration;
import io.cloudbeaver.registry.WebAuthProviderDescriptor;
import io.cloudbeaver.server.CBApplication;
Expand All @@ -39,9 +40,11 @@ public class WebAuthProviderInfo {
private static final Log log = Log.getLog(WebAuthProviderInfo.class);

private final WebAuthProviderDescriptor descriptor;
private final WebSession webSession;

public WebAuthProviderInfo(WebAuthProviderDescriptor descriptor) {
public WebAuthProviderInfo(WebSession webSession, WebAuthProviderDescriptor descriptor) {
this.descriptor = descriptor;
this.webSession = webSession;
}

WebAuthProviderDescriptor getDescriptor() {
Expand Down

0 comments on commit 33ba65b

Please sign in to comment.