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: PGSql MTLS support #31067

Merged
merged 18 commits into from Mar 4, 2024
Merged

feat: PGSql MTLS support #31067

merged 18 commits into from Mar 4, 2024

Conversation

AnaghHegde
Copy link
Member

@AnaghHegde AnaghHegde commented Feb 12, 2024

Description

Mutual TLS, or mTLS for short, is a method for mutual authentication. mTLS ensures that the parties at each end of a network connection are who they claim to be by verifying that they both have the correct private key.
This PR adds support for mTLS for postgres datasource. Unlike the standard way of storing the certs in disk, we store them in the database. This has been achieved via the custom implementation of SSL Factory. The postgres driver support passing the custom ssl factory while creating connection, which then will be used for handling and establishing the connection.

PR fixes following issue(s)

Fixes #31326

Type of change

  • New feature (non-breaking change which adds functionality)

Testing

How Has This Been Tested?

  • Manual

Test Plan

Add Testsmith test cases links that relate to this PR

Issues raised during DP testing

Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)

Checklist:

Dev activity

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • PR is being merged under a feature flag

QA activity:

  • Speedbreak features have been covered
  • Test plan covers all impacted features and areas of interest
  • Test plan has been peer reviewed by project stakeholders and other QA members
  • Manually tested functionality on DP
  • We had an implementation alignment call with stakeholders post QA Round 2
  • Cypress test cases have been added and approved by SDET/manual QA
  • Added Test Plan Approved label after Cypress tests were reviewed
  • Added Test Plan Approved label after JUnit tests were reviewed

Summary by CodeRabbit

  • New Features
    • Enhanced the Postgres plugin to support SSL certificate validation for secure database connections. Users can now select between VERIFY_CA and VERIFY_FULL modes for SSL verification, ensuring a higher level of security for database communications.

@AnaghHegde AnaghHegde self-assigned this Feb 12, 2024
@AnaghHegde AnaghHegde marked this pull request as draft February 12, 2024 17:03
Copy link
Contributor

coderabbitai bot commented Feb 12, 2024

Walkthrough

The update introduces SSL certificate validation for the Postgres plugin, enhancing security by verifying server certificates against known CAs. It adds two verification levels, VERIFY_CA and VERIFY_FULL, to the connection setup process. Additionally, a new class, StringCertValidatingFactory, is created to manage the conversion of certificates and keys, setup of keystores and truststores, and initialization of SSLContext for secure database connections.

Changes

File Path Change Summary
.../postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java Added VERIFY_CA and VERIFY_FULL cases in createConnectionPool for SSL certificate validation.
.../postgresPlugin/src/main/java/com/external/plugins/utils/StringCertValidatingFactory.java Introduced to handle certificate conversion, keystore and truststore setup, and SSLContext initialization.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

Failed server tests

  • com.appsmith.server.solutions.ShareWorkspacePermissionTests#testAdminInviteRoles

@AnaghHegde AnaghHegde changed the title Feat/pgsql ca cert auth support feat: PGSql MTLS support Feb 13, 2024
@github-actions github-actions bot added the Enhancement New feature or request label Feb 13, 2024
@AnaghHegde
Copy link
Member Author

/build-deploy-preview

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/7914129925.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 31067.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-31067.dp.appsmith.com

Copy link

This PR has not seen activitiy for a while. It will be closed in 7 days unless further activity is detected.

@github-actions github-actions bot added the Stale label Feb 22, 2024
@AnaghHegde AnaghHegde marked this pull request as ready for review February 28, 2024 05:20
Copy link

Failed server tests

  • com.appsmith.server.services.LayoutServiceTest#createLayoutWithInvalidPageID

@AnaghHegde AnaghHegde requested a review from sumitsum March 4, 2024 05:38
@github-actions github-actions bot added BE Coders Pod Issues related to users writing code to fetch and update data Integrations Pod Issues related to a specific integration Postgres Postgres related issues Task A simple Todo Templates Issues related to templates Templates Pod Issues related to Templates labels Mar 4, 2024
@rahulbarwal rahulbarwal merged commit 8d696f1 into release Mar 4, 2024
13 checks passed
@rahulbarwal rahulbarwal deleted the feat/pgsql-ca-cert-auth-support branch March 4, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE Coders Pod Issues related to users writing code to fetch and update data Enhancement New feature or request Integrations Pod Issues related to a specific integration Postgres Postgres related issues Stale Task A simple Todo Templates Pod Issues related to Templates Templates Issues related to templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support uploading a SSL CA certificate for Postgres datasource
3 participants