Skip to content

Commit

Permalink
Add authType to tenant settings (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
slavikm authored May 20, 2024
1 parent df07bc0 commit 7c509a2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/management-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dependency>
<groupId>com.descope</groupId>
<artifactId>java-sdk</artifactId>
<version>1.0.22</version>
<version>1.0.23</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.descope</groupId>
<artifactId>java-sdk</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.0.22</version>
<version>1.0.23</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>Java library used to integrate with Descope.</description>
<url>https://github.com/descope/descope-java</url>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/descope/enums/TenantAuthType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.descope.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

public enum TenantAuthType {
OIDC("oidc"),
SAML("saml"),
NONE("none");

@Getter
@JsonValue
private final String value;

TenantAuthType(String value) {
this.value = value;
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/descope/model/tenant/TenantSettings.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.descope.model.tenant;

import com.descope.enums.TenantAuthType;
import com.fasterxml.jackson.annotation.JsonAlias;
import java.util.List;
import lombok.AllArgsConstructor;
Expand All @@ -25,4 +26,5 @@ public class TenantSettings {
String inactivityTimeUnit;
@JsonAlias({"JITDisabled"})
Boolean jitDisabled;
TenantAuthType authType; // authType can be either "oidc" or "saml"
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ public void configureSettings(String id, TenantSettings settings) throws Descope
if (settings == null) {
throw ServerCommonException.invalidArgument("settings");
}
if (settings.getAuthType() == null && settings.getJitDisabled() != null) {
throw ServerCommonException.invalidArgument("settings.authType");
}
Map<String, Object> req = mapOf("tenantId", id);
addIfNotNull(req, "selfProvisioningDomains", settings.getSelfProvisioningDomains());
addIfNotNull(req, "enabled", settings.getSessionSettingsEnabled());
Expand All @@ -173,6 +176,7 @@ public void configureSettings(String id, TenantSettings settings) throws Descope
addIfNotNull(req, "enableInactivity", settings.getEnableInactivity());
addIfNotNull(req, "domains", settings.getDomains());
addIfNotNull(req, "JITDisabled", settings.getJitDisabled());
addIfNotNull(req, "authType", settings.getAuthType());
ApiProxy apiProxy = getApiProxy();
apiProxy.post(configureSettingsUri(), req, Void.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import com.descope.enums.TenantAuthType;
import com.descope.exception.RateLimitExceededException;
import com.descope.exception.ServerCommonException;
import com.descope.model.client.Client;
Expand Down Expand Up @@ -259,10 +260,12 @@ void testFunctionalFullCycle() {
assertThat(tenants).isEmpty();

tenantSettings.setJitDisabled(true);
tenantSettings.setAuthType(TenantAuthType.OIDC);
tenantService.configureSettings(tenantId, tenantSettings);
tenantSettings = tenantService.getSettings(tenantId);
assertThat(tenantSettings).isNotNull();
assertThat(tenantSettings.getJitDisabled()).isTrue();
assertThat(tenantSettings.getAuthType()).isEqualTo(TenantAuthType.OIDC);
tenantService.delete(tenantId);
}
}

0 comments on commit 7c509a2

Please sign in to comment.