Skip to content
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

CB-5734 return template configuration for auth provider #3162

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -29,8 +29,8 @@
*/
public interface SMAuthProviderFederated extends SMSignOutLinkProvider {

@NotNull

Check warning on line 32 in server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/auth/SMAuthProviderFederated.java

View workflow job for this annotation

GitHub Actions / Server / Lint

[checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/auth/SMAuthProviderFederated.java:32:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
String getSignInLink(String id, @NotNull Map<String, Object> providerConfig) throws DBException;
String getSignInLink(String id) throws DBException;

@Override
default String getUserSignOutLink(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public Map<String, Object> getParameters() {
@Property
public String getSignInLink() throws DBException {
SMAuthProvider<?> instance = providerDescriptor.getInstance();
return instance instanceof SMAuthProviderFederated ?
buildRedirectUrl(((SMAuthProviderFederated) instance).getSignInLink(getId(), config.getParameters()))
return instance instanceof SMAuthProviderFederated smAuthProviderFederated ?
buildRedirectUrl(smAuthProviderFederated.getSignInLink(getId()))
: null;
}

Expand All @@ -86,34 +86,40 @@ private String buildRedirectUrl(String baseUrl) {
@Property
public String getSignOutLink() throws DBException {
SMAuthProvider<?> instance = providerDescriptor.getInstance();
return instance instanceof SMSignOutLinkProvider
? ((SMSignOutLinkProvider) instance).getCommonSignOutLink(getId(), config.getParameters())
return instance instanceof SMSignOutLinkProvider smSignOutLinkProvider
? smSignOutLinkProvider.getCommonSignOutLink(getId(), config.getParameters())
: null;
}

@Property
public String getRedirectLink() throws DBException {
SMAuthProvider<?> instance = providerDescriptor.getInstance();
return instance instanceof SMAuthProviderFederated ? ((SMAuthProviderFederated) instance).getRedirectLink(getId(), config.getParameters()) : null;
return instance instanceof SMAuthProviderFederated smAuthProviderFederated
? smAuthProviderFederated.getRedirectLink(getId(), config.getParameters())
: null;
}

@Property
public String getMetadataLink() throws DBException {
SMAuthProvider<?> instance = providerDescriptor.getInstance();
return instance instanceof SMAuthProviderFederated ? ((SMAuthProviderFederated) instance).getMetadataLink(getId(), config.getParameters()) : null;
return instance instanceof SMAuthProviderFederated smAuthProviderFederated
? smAuthProviderFederated.getMetadataLink(getId(), config.getParameters())
: null;
}

@Property
public String getAcsLink() throws DBException {
SMAuthProvider<?> instance = providerDescriptor.getInstance();
return instance instanceof SMAuthProviderFederated ? ((SMAuthProviderFederated) instance).getAcsLink(getId(), config.getParameters()) : null;
return instance instanceof SMAuthProviderFederated smAuthProviderFederated
? smAuthProviderFederated.getAcsLink(getId(), config.getParameters())
: null;
}

@Property
public String getEntityIdLink() throws DBException {
SMAuthProvider<?> instance = providerDescriptor.getInstance();
return instance instanceof SMAuthProviderFederated
? ((SMAuthProviderFederated) instance).getEntityIdLink(getId(), config.getParameters())
return instance instanceof SMAuthProviderFederated smAuthProviderFederated
? smAuthProviderFederated.getEntityIdLink(getId(), config.getParameters())
: null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ type AuthProviderInfo {
# Provider configurations (applicable only if configurable=true)
configurations: [AuthProviderConfiguration!]

templateConfiguration: AuthProviderConfiguration! @since(version: "24.1.2")

credentialProfiles: [AuthProviderCredentialsProfile!]!

requiredFeatures: [String!]!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
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;
import io.cloudbeaver.server.WebAppUtils;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.security.SMAuthCredentialsProfile;
import org.jkiss.dbeaver.model.security.SMAuthProviderCustomConfiguration;
Expand All @@ -38,17 +38,15 @@
public class WebAuthProviderInfo {

private static final Log log = Log.getLog(WebAuthProviderInfo.class);
private static final SMAuthProviderCustomConfiguration TEMPLATE_CONFIG = new SMAuthProviderCustomConfiguration("{configuration_id}");

@NotNull
private final WebAuthProviderDescriptor descriptor;

public WebAuthProviderInfo(WebAuthProviderDescriptor descriptor) {
public WebAuthProviderInfo(@NotNull WebAuthProviderDescriptor descriptor) {
this.descriptor = descriptor;
}

WebAuthProviderDescriptor getDescriptor() {
return descriptor;
}

public String getId() {
return descriptor.getId();
}
Expand Down Expand Up @@ -126,6 +124,10 @@ public String[] getRequiredFeatures() {
return rf == null ? new String[0] : rf;
}

public WebAuthProviderConfiguration getTemplateConfiguration() {
return new WebAuthProviderConfiguration(descriptor, TEMPLATE_CONFIG);
}

@Override
public String toString() {
return getLabel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ public SMAuthInfo authenticate(
if (SMAuthProviderFederated.class.isAssignableFrom(authProviderInstance.getClass())) {
//async auth
var authProviderFederated = (SMAuthProviderFederated) authProviderInstance;
String signInLink = buildRedirectLink(authProviderFederated.getSignInLink(authProviderConfigurationId, Map.of()),
String signInLink = buildRedirectLink(authProviderFederated.getSignInLink(authProviderConfigurationId),
authAttemptId);
String signOutLink = authProviderFederated.getCommonSignOutLink(authProviderConfigurationId,
providerConfig.getParameters());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ fragment AuthProviderInfo on AuthProviderInfo {
supportProvisioning
required
authHidden
templateConfiguration {
id
signInLink
signOutLink
metadataLink
acsLink
entityIdLink
}

#configurationParameters {
# id
Expand Down
Loading