Skip to content

Commit

Permalink
feat: added auth url and base url as enabling factor
Browse files Browse the repository at this point in the history
  • Loading branch information
1nb0und committed Dec 15, 2023
1 parent f446fb6 commit 0185572
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
Expand All @@ -19,6 +20,7 @@
*/
@Deprecated
@Conditional(CamundaOperateClientCondition.class)
@ConditionalOnProperty(prefix = "camunda.operate.client", name = "enabled", havingValue = "true", matchIfMissing = true)
@EnableConfigurationProperties(CamundaOperateClientConfigurationProperties.class)
public class CamundaOperateClientConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ public CamundaOperateClientCondition() {
}

@ConditionalOnProperty(name = "camunda.operate.client.client-id")
static class ClientIdCondition {

}
static class ClientIdCondition { }

@ConditionalOnProperty(name = "camunda.operate.client.username")
static class UsernameCondition {
static class UsernameCondition { }

}
@ConditionalOnProperty(name = "camunda.operate.client.auth-url")
static class AuthUrlCondition { }

@ConditionalOnProperty(name = "camunda.operate.client.base-url")
static class BaseUrlCondition { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ public OperateClientCondition() {
}

@ConditionalOnProperty(name = "operate.client.client-id")
static class ClientIdCondition {

}
static class ClientIdCondition { }

@ConditionalOnProperty(name = "operate.client.username")
static class UsernameCondition {
static class UsernameCondition { }

}
@ConditionalOnProperty(name = "operate.client.auth-url")
static class AuthUrlCondition { }

@ConditionalOnProperty(name = "operate.client.base-url")
static class BaseUrlCondition { }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.camunda.zeebe.spring.client.properties;

import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -26,7 +27,7 @@ public class CamundaOperateClientConfigurationProperties {
private String clientSecret;
private String username;
private String password;
private Boolean enabled;
private Boolean enabled = false;
private String url;

private String keycloakUrl;
Expand Down Expand Up @@ -131,4 +132,15 @@ public String getOperateUrl() {
throw new IllegalArgumentException(
"In order to connect to Camunda Operate you need to specify either a SaaS clusterId or an Operate URL.");
}

@PostConstruct
private void applyFinalValues() {
if (this.getClientId() != null && this.getClientSecret() != null) {
this.setEnabled(true);
} else if (this.getUsername() != null && this.getPassword() != null) {
this.setEnabled(true);
} else if (this.getAuthUrl() != null || this.getBaseUrl() != null) {
this.setEnabled(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ private void applyFinalValues() {
this.setEnabled(true);
} else if (this.getUsername() != null && this.getPassword() != null) {
this.setEnabled(true);
} else if (this.getAuthUrl() != null || this.getBaseUrl() != null) {
this.setEnabled(true);
}
}
}

0 comments on commit 0185572

Please sign in to comment.