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

feat: add recaptcha verification for user signup #3319

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a820728
Merge pull request #2416 from appsmithorg/release
hetunandu Jan 4, 2021
45918bf
Fix invalid toast message for evaluation error (#2443)
hetunandu Jan 5, 2021
db2b002
Increased logs to debug future connection leaks. (#2437)
trishaanand Jan 5, 2021
d1d7307
Adding action execution time and logging the same (#2473)
trishaanand Jan 7, 2021
1e17c03
Fix onboarding test failure causing other tests to fail (#2417)
akash-codemonk Jan 4, 2021
6e4cdb0
Hide other header elements while showing the deploy button
akash-codemonk Jan 6, 2021
b5a1c93
Open the already opened tab if it exists when clicking on deploy (#2448)
akash-codemonk Jan 6, 2021
44e300e
Onboarding fixes (#2458)
akash-codemonk Jan 8, 2021
09c4e4f
Onboarding deploy tooltip fix (#2490)
akash-codemonk Jan 11, 2021
63fb249
Merge branch 'release'
sharat87 Jan 20, 2021
ee985af
Merge branch 'release'
hetunandu Jan 20, 2021
4014e52
Never show the redux action type in toast errors (#2635)
hetunandu Jan 21, 2021
95250cf
Merge branch 'release'
sharat87 Jan 21, 2021
317fa1e
Remove duplicate function definition
sharat87 Jan 21, 2021
1e8aa62
Merge branch 'release'
sharat87 Jan 22, 2021
dc4e741
Add Sentry token to enable Sentry integration (#2674)
sharat87 Jan 22, 2021
3deb106
Add message re telemetry during installation (#2621)
sharat87 Jan 22, 2021
433461a
Merge pull request #2759 from appsmithorg/release
mohanarpit Jan 28, 2021
779c41e
Merge branch 'release'
sharat87 Feb 3, 2021
ebcbfb0
Merge branch 'release'
sharat87 Feb 8, 2021
79d1d6d
Update UploadingAssets.md
Nikhil-Nandagopal Feb 10, 2021
95d1717
Merge branch 'release'
sharat87 Feb 10, 2021
464bffa
Merge branch 'release'
sharat87 Feb 10, 2021
7f58e89
Fix input error on generating password and salt in install script (#3…
sharat87 Feb 16, 2021
9c20ac5
New onboarding flow (#2686)
akash-codemonk Feb 11, 2021
e604357
Go back to application list instead of deleting app (#2981)
akash-codemonk Feb 11, 2021
86725ba
Update onboarding indicator animation for widget menu (#3018)
akash-codemonk Feb 15, 2021
c80b6b4
Include Firestore document metadata in responses (#3063)
sharat87 Feb 16, 2021
036cb95
Push explicitly specified tags to Docker (#2988)
sharat87 Feb 11, 2021
128444f
Add more information for action execution (#3060)
sharat87 Feb 18, 2021
60a4ddb
Fix NPE on plugin specified templates (#3084)
sharat87 Feb 18, 2021
ef732f1
Add request body and some other details in action execution data poin…
sharat87 Feb 19, 2021
805e306
Updating app.json for Heroku deploy
mohanarpit Feb 19, 2021
276338a
Rename the $ref field to _ref in Firestore plugin (#3135)
sharat87 Feb 22, 2021
577714b
Update issue templates
Nikhil-Nandagopal Feb 24, 2021
2dfb4ac
Updated issue template
Nikhil-Nandagopal Feb 24, 2021
d420518
Fixing merge conflicts
mohanarpit Feb 25, 2021
4f16b23
Merge branch 'release'
mohanarpit Feb 25, 2021
73d4741
Merge branch 'release'
mohanarpit Feb 25, 2021
3e7d2bb
Merge branch 'release' of github.com:appsmithorg/appsmith
riodeuno Feb 25, 2021
3cc1fbf
Merge branch 'release'
hetunandu Feb 25, 2021
bf16b45
Merge pull request #3309 from appsmithorg/release
mohanarpit Mar 2, 2021
f1ac423
add: services & config boilerplate for Google Recaptcha Service
Feb 27, 2021
168ab83
add: implementation of google recaptcha verify api
Feb 27, 2021
d119a43
add: working functionality for recaptcha
Feb 27, 2021
1c8498b
fix: import order
Mar 2, 2021
50a889b
fix: appErrorCode values
Mar 2, 2021
d226c6d
fix: return type mismatch error
Mar 2, 2021
12652e6
fix: failing build & code cleanup
Mar 2, 2021
f76a3c6
rename: GoogleRecaptchaService to CaptchaService, fix: typos & resolv…
Mar 3, 2021
76de20b
fix: revert UserController & add captcha verfication to UserService
Mar 3, 2021
5b74643
remove: isEnabled flag for GoogleRecaptchaConfig
Mar 3, 2021
67ece23
cleanup: env example files
Mar 3, 2021
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
Prev Previous commit
Next Next commit
Increased logs to debug future connection leaks. (#2437)
* Increased logs to debug future connection leaks.

* Fetch a connection from the pool only if a query exists.

* Minor comment added.

* Minor rewrite

* Code formatting.

* Update app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java

Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>

* Added hikari cp pool stats to get database structure function as well.

Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
  • Loading branch information
trishaanand and sharat87 committed Jan 5, 2021
commit db2b002ac76b08c638be022b9e98cd30b55d8b75
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.appsmith.external.plugins.PluginExecutor;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import com.zaxxer.hikari.HikariPoolMXBean;
import org.apache.commons.lang.ObjectUtils;
import org.pf4j.Extension;
import org.pf4j.PluginWrapper;
Expand Down Expand Up @@ -52,7 +53,7 @@ public class PostgresPlugin extends BasePlugin {

private static final int MINIMUM_POOL_SIZE = 1;

private static final int MAXIMUM_POOL_SIZE = 20;
private static final int MAXIMUM_POOL_SIZE = 5;

private static final long LEAK_DETECTION_TIME_MS = 60*1000;

Expand Down Expand Up @@ -114,27 +115,41 @@ public Mono<ActionExecutionResult> execute(HikariDataSource connection,

return Mono.fromCallable(() -> {

Connection connectionFromPool;

try {
connectionFromPool = getConnectionFromConnectionPool(connection, datasourceConfiguration);
} catch (StaleConnectionException e) {
return Mono.error(e);
} catch (SQLException e) {
return Mono.error(new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, e.getMessage()));
}

String query = actionConfiguration.getBody();
// Check for query parameter before performing the probably expensive fetch connection from the pool op.
if (query == null) {
return Mono.error(new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, "Missing required parameter: Query."));
}

Connection connectionFromPool = null;

try {
connectionFromPool = getConnectionFromConnectionPool(connection, datasourceConfiguration);
} catch (SQLException | StaleConnectionException e) {
// The function can throw either StaleConnectionException or SQLException. The underlying hikari
// library throws SQLException in case the pool is closed or there is an issue initializing
// the connection pool which can also be translated in our world to StaleConnectionException
// and should then trigger the destruction and recreation of the pool.
return Mono.error(e instanceof StaleConnectionException ? e : new StaleConnectionException());
}

List<Map<String, Object>> rowsList = new ArrayList<>(50);

Statement statement = null;
ResultSet resultSet = null;
System.out.println(Thread.currentThread().getName() +
": Going to execute query" + query);

HikariPoolMXBean poolProxy = connection.getHikariPoolMXBean();

int idleConnections = poolProxy.getIdleConnections();
int activeConnections = poolProxy.getActiveConnections();
int totalConnections = poolProxy.getTotalConnections();
int threadsAwaitingConnection = poolProxy.getThreadsAwaitingConnection();
System.out.println(Thread.currentThread().getName() + ": Before executing postgres query [" +
query +
"] Hikari Pool stats : active - " + activeConnections +
", idle - " + idleConnections +
", awaiting - " + threadsAwaitingConnection +
", total - " + totalConnections );
try {
statement = connectionFromPool.createStatement();
boolean isResultSet = statement.execute(query);
Expand Down Expand Up @@ -197,8 +212,17 @@ public Mono<ActionExecutionResult> execute(HikariDataSource connection,
}

} catch (SQLException e) {
System.out.println(Thread.currentThread().getName() + ": In the PostgresPlugin, got action execution error");
return Mono.error(new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, e.getMessage()));
} finally {
idleConnections = poolProxy.getIdleConnections();
activeConnections = poolProxy.getActiveConnections();
totalConnections = poolProxy.getTotalConnections();
threadsAwaitingConnection = poolProxy.getThreadsAwaitingConnection();
System.out.println(Thread.currentThread().getName() + ": After executing postgres query, Hikari Pool stats active - " + activeConnections +
", idle - " + idleConnections +
", awaiting - " + threadsAwaitingConnection +
", total - " + totalConnections );
if (resultSet != null) {
try {
resultSet.close();
Expand Down Expand Up @@ -334,12 +358,26 @@ public Mono<DatasourceStructure> getStructure(HikariDataSource connection, Datas
Connection connectionFromPool;
try {
connectionFromPool = getConnectionFromConnectionPool(connection, datasourceConfiguration);
} catch (StaleConnectionException e) {
return Mono.error(e);
} catch (SQLException e) {
return Mono.error(new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, e.getMessage()));
} catch (SQLException | StaleConnectionException e) {
// The function can throw either StaleConnectionException or SQLException. The underlying hikari
// library throws SQLException in case the pool is closed or there is an issue initializing
// the connection pool which can also be translated in our world to StaleConnectionException
// and should then trigger the destruction and recreation of the pool.
return Mono.error(e instanceof StaleConnectionException ? e : new StaleConnectionException());
}

HikariPoolMXBean poolProxy = connection.getHikariPoolMXBean();

int idleConnections = poolProxy.getIdleConnections();
int activeConnections = poolProxy.getActiveConnections();
int totalConnections = poolProxy.getTotalConnections();
int threadsAwaitingConnection = poolProxy.getThreadsAwaitingConnection();
System.out.println(Thread.currentThread().getName() + ": Before getting postgres db structure" +
" Hikari Pool stats : active - " + activeConnections +
", idle - " + idleConnections +
", awaiting - " + threadsAwaitingConnection +
", total - " + totalConnections );

// Ref: <https://docs.oracle.com/en/java/javase/11/docs/api/java.sql/java/sql/DatabaseMetaData.html>.
try (Statement statement = connectionFromPool.createStatement()) {

Expand Down Expand Up @@ -467,6 +505,14 @@ public Mono<DatasourceStructure> getStructure(HikariDataSource connection, Datas
} catch (SQLException throwable) {
return Mono.error(throwable);
} finally {
idleConnections = poolProxy.getIdleConnections();
activeConnections = poolProxy.getActiveConnections();
totalConnections = poolProxy.getTotalConnections();
threadsAwaitingConnection = poolProxy.getThreadsAwaitingConnection();
System.out.println(Thread.currentThread().getName() + ": After postgres db structure, Hikari Pool stats active - " + activeConnections +
", idle - " + idleConnections +
", awaiting - " + threadsAwaitingConnection +
", total - " + totalConnections );

if (connectionFromPool != null) {
try {
Expand Down Expand Up @@ -496,8 +542,7 @@ public Mono<DatasourceStructure> getStructure(HikariDataSource connection, Datas
* @param datasourceConfiguration
* @return connection pool
*/
private static HikariDataSource createConnectionPool(DatasourceConfiguration datasourceConfiguration)
{
private static HikariDataSource createConnectionPool(DatasourceConfiguration datasourceConfiguration) {
HikariConfig config = new HikariConfig();

config.setDriverClassName(JDBC_DRIVER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ public Mono<ActionExecutionResult> executeAction(ExecuteActionDTO executeActionD
)
)
.onErrorResume(e -> {
log.debug("In the action execution error mode.", e);
log.debug("{}: In the action execution error mode.",
Thread.currentThread().getName(), e);
ActionExecutionResult result = new ActionExecutionResult();
result.setBody(e.getMessage());
result.setIsExecutionSuccess(false);
Expand Down