Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
prateek3255 committed Feb 23, 2024
2 parents 4da5a36 + 79f6ef7 commit c3673f9
Show file tree
Hide file tree
Showing 12 changed files with 305 additions and 66 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Adds implementation for a new method `getConfigFieldsJson` to fetch the plugin config fields.
- Adds implementation for a new method `getConfigFieldsInfo` to fetch the plugin config fields.

## [5.0.8] - 2024-02-19

- Fixes vulnerabilities in dependencies

## [5.0.7] - 2024-01-25

- Fixes the issue where passwords were inadvertently logged in the logs.
- Adds tests to check connection pool behaviour.
- Adds `postgresql_idle_connection_timeout` and `postgresql_minimum_idle_connections` configs to control active connections to the database.

## [5.0.6] - 2023-12-05

Expand Down
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java-library'
}

version = "5.0.7"
version = "5.0.8"

repositories {
mavenCentral()
Expand All @@ -17,16 +17,16 @@ dependencies {
implementation group: 'com.zaxxer', name: 'HikariCP', version: '3.4.1'

// https://mvnrepository.com/artifact/org.postgresql/postgresql
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.10'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.7.1'

// https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml
compileOnly group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.14.0'
compileOnly group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.14.2'

// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compileOnly group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.0'
compileOnly group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.1'

// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
compileOnly group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compileOnly group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.14'

// https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305
compileOnly group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
Expand All @@ -43,21 +43,21 @@ dependencies {
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.1.0'

// https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core
testImplementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '10.1.1'
testImplementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '10.1.18'

// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.14'

// https://mvnrepository.com/artifact/com.google.code.gson/gson
testImplementation group: 'com.google.code.gson', name: 'gson', version: '2.3.1'

testImplementation 'com.tngtech.archunit:archunit-junit4:0.22.0'

// https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml
testImplementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.14.0'
testImplementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.14.2'

// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.0'
testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.1'
}

jar {
Expand Down
8 changes: 8 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,11 @@ postgresql_config_version: 0
# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: "thirdparty_users") string value. Specify the name of the table
# that will store the thirdparty recipe users.
# postgresql_thirdparty_users_table_name:

# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: 60000) long value. Timeout in milliseconds for the idle connections
# to be closed.
# postgresql_idle_connection_timeout:

# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: null) integer value. Minimum number of idle connections to be kept
# active. If not set, minimum idle connections will be same as the connection pool size.
# postgresql_minimum_idle_connections:
8 changes: 8 additions & 0 deletions devConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,11 @@ postgresql_password: "root"
# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: "thirdparty_users") string value. Specify the name of the table
# that will store the thirdparty recipe users.
# postgresql_thirdparty_users_table_name:

# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: 60000) long value. Timeout in milliseconds for the idle connections
# to be closed.
# postgresql_idle_connection_timeout:

# (DIFFERENT_ACROSS_TENANTS | OPTIONAL | Default: null) integer value. Minimum number of idle connections to be kept
# active. If not set, minimum idle connections will be same as the connection pool size.
# postgresql_minimum_idle_connections:
6 changes: 3 additions & 3 deletions implementationDependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"_comment": "Contains list of implementation dependencies URL for this project",
"list": [
{
"jar": "https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.10/postgresql-42.2.10.jar",
"name": "PostgreSQL JDBC Driver 4.2",
"src": "https://repo1.maven.org/maven2/org/postgresql/postgresql/42.2.10/postgresql-42.2.10-sources.jar"
"jar": "https://repo1.maven.org/maven2/org/postgresql/postgresql/42.7.1/postgresql-42.7.1.jar",
"name": "PostgreSQL JDBC Driver 42.7.1",
"src": "https://repo1.maven.org/maven2/org/postgresql/postgresql/42.7.1/postgresql-42.7.1-sources.jar"
},
{
"jar": "https://repo1.maven.org/maven2/com/zaxxer/HikariCP/3.4.1/HikariCP-3.4.1.jar",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ private synchronized void initialiseHikariDataSource() throws SQLException {
}
config.setMaximumPoolSize(userConfig.getConnectionPoolSize());
config.setConnectionTimeout(5000);
if (userConfig.getMinimumIdleConnections() != null) {
config.setMinimumIdle(userConfig.getMinimumIdleConnections());
config.setIdleTimeout(userConfig.getIdleConnectionTimeout());
}
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/supertokens/storage/postgresql/Start.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public class Start
// SaaS. If the core is not running in SuperTokens SaaS, this array has no effect.
private static String[] PROTECTED_DB_CONFIG = new String[]{"postgresql_connection_pool_size",
"postgresql_connection_uri", "postgresql_host", "postgresql_port", "postgresql_user", "postgresql_password",
"postgresql_database_name", "postgresql_table_schema"};
"postgresql_database_name", "postgresql_table_schema", "postgresql_idle_connection_timeout",
"postgresql_minimum_idle_connections"};
private static final Object appenderLock = new Object();
public static boolean silent = false;
private ResourceDistributor resourceDistributor = new ResourceDistributor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ public class PostgreSQLConfig {
@ConfigDescription("The scheme of the PostgreSQL database.")
private String postgresql_connection_scheme = "postgresql";

@JsonProperty
@ConnectionPoolProperty
@ConfigDescription("Timeout in milliseconds for the idle connections to be closed. (Default: 60000)")
private long postgresql_idle_connection_timeout = 60000;

@JsonProperty
@ConnectionPoolProperty
@ConfigDescription("Minimum number of idle connections to be kept active. If not set, minimum idle connections will be same as the connection pool size. (Default: null)")
private Integer postgresql_minimum_idle_connections = null;

@IgnoreForAnnotationCheck
boolean isValidAndNormalised = false;

Expand Down Expand Up @@ -294,6 +304,14 @@ public String getThirdPartyUsersTable() {
return postgresql_thirdparty_users_table_name;
}

public long getIdleConnectionTimeout() {
return postgresql_idle_connection_timeout;
}

public Integer getMinimumIdleConnections() {
return postgresql_minimum_idle_connections;
}

public String getThirdPartyUserToTenantTable() {
return addSchemaAndPrefixToTableName("thirdparty_user_to_tenant");
}
Expand Down Expand Up @@ -400,6 +418,19 @@ public void validateAndNormalise() throws InvalidConfigException {
"'postgresql_connection_pool_size' in the config.yaml file must be > 0");
}

if (postgresql_minimum_idle_connections != null) {
if (postgresql_minimum_idle_connections < 0) {
throw new InvalidConfigException(
"'postgresql_minimum_idle_connections' must be >= 0");
}

if (postgresql_minimum_idle_connections > postgresql_connection_pool_size) {
throw new InvalidConfigException(
"'postgresql_minimum_idle_connections' must be less than or equal to "
+ "'postgresql_connection_pool_size'");
}
}

// Normalisation
if (postgresql_connection_uri != null) {
{ // postgresql_connection_attributes
Expand Down
Loading

0 comments on commit c3673f9

Please sign in to comment.