<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ovianta</title>
    <description>The latest articles on DEV Community by Ovianta (@ovianta).</description>
    <link>https://dev.to/ovianta</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F9793%2F03f7a894-d34c-491e-a0b4-25d70a9552a0.jpeg</url>
      <title>DEV Community: Ovianta</title>
      <link>https://dev.to/ovianta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ovianta"/>
    <language>en</language>
    <item>
      <title>Enhancing Data Security with MongoDB: A Dive into Cryptography and CSFLE at Ovianta</title>
      <dc:creator>Rubén Martín Pozo</dc:creator>
      <pubDate>Mon, 02 Dec 2024 10:20:00 +0000</pubDate>
      <link>https://dev.to/ovianta/enhancing-data-security-with-mongodb-a-dive-into-cryptography-and-csfle-at-ovianta-47d</link>
      <guid>https://dev.to/ovianta/enhancing-data-security-with-mongodb-a-dive-into-cryptography-and-csfle-at-ovianta-47d</guid>
      <description>&lt;p&gt;In the digital age, safeguarding sensitive information is not optional. It's essential. At Ovianta, a SaaS solution empowering doctors with streamlined workflows and intelligent insights, protecting patient data is a top priority. MongoDB's cryptographic tools, particularly Client-Side Field Level Encryption (CSFLE), offer powerful methods to secure data in-use.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore MongoDB's CSFLE and share how Ovianta leverages encryption to meet stringent data protection requirements while working within the constraints of serverless environments like Vercel.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Client-Side Field Level Encryption?
&lt;/h2&gt;

&lt;p&gt;MongoDB's CSFLE encrypts specific fields on the client side, ensuring sensitive data remains inaccessible to unauthorized parties, even if the database itself is compromised. The approach aligns with compliance standards like GDPR and HIPAA, making it an excellent choice for industries handling sensitive information, such as healthcare.&lt;/p&gt;

&lt;p&gt;CSFLE Highlights:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data confidentiality: Data is encrypted before it leaves the client.&lt;/li&gt;
&lt;li&gt;Field-level granularity: Only sensitive fields are encrypted, leaving the rest of the database searchable.&lt;/li&gt;
&lt;li&gt;Compliance-friendly: Helps meet data protection regulations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Automatic vs. Manual Encryption
&lt;/h2&gt;

&lt;p&gt;MongoDB supports two CSFLE modes: Automatic Encryption and Manual Encryption.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Automatic Encryption:

&lt;ul&gt;
&lt;li&gt;Simplifies implementation by using MongoDB drivers to handle encryption.&lt;/li&gt;
&lt;li&gt;Requires the installation of an extra library.&lt;/li&gt;
&lt;li&gt;Not compatible with all hosting environments, including serverless platforms like Vercel.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Manual Encryption:

&lt;ul&gt;
&lt;li&gt;Offers fine-grained control by letting developers manage encryption and decryption explicitly.&lt;/li&gt;
&lt;li&gt;Does not rely on additional libraries, making it suitable for environments with strict resource constraints, including serverless platforms like Vercel.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At Ovianta, we chose manual encryption because automatic encryption's library is incompatible with Vercel's serverless architecture. This decision ensures we maintain robust security without compromising the performance or scalability of our platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Manual Encryption: How Ovianta Secures Data
&lt;/h2&gt;

&lt;p&gt;At Ovianta, we handle sensitive patient information, such as medical histories and consultation records. Using manual encryption allows us to encrypt this data securely before storing it in MongoDB. Here's how we do it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Key Management:

&lt;ul&gt;
&lt;li&gt;We generate and manage Data Encryption Keys (DEKs) using a secure Key Management System (KMS).&lt;/li&gt;
&lt;li&gt;Our KMS integrates seamlessly with MongoDB, providing a secure mechanism for key storage.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Encryption and Decryption:

&lt;ul&gt;
&lt;li&gt;Data is encrypted using the MongoDB Client Encryption Library before it is sent to the database.&lt;/li&gt;
&lt;li&gt;Authorized services decrypt data when needed, ensuring only specific application workflows can access sensitive information.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ClientEncryption&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mongodb-client-encryption&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Initialize encryption settings&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clientEncryption&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ClientEncryption&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;keyVaultNamespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;encryption.__keyVault&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;kmsProviders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;aws&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;accessKeyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;AWS_ACCESS_KEY_ID&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;secretAccessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;AWS_SECRET_ACCESS_KEY&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Encrypt sensitive patient data&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;encryptedValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;clientEncryption&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;patientSensitiveData&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;keyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;keyId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;algorithm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Store encrypted data in MongoDB&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insertOne&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;sensitiveField&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;encryptedValue&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's also possible to decrypt using the MongoClient directly without needing to activate full automatic encryption by using the property &lt;strong&gt;bypassAutoEncryption&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;secureClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MongoClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;autoEncryption&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;keyVaultNamespace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nx"&gt;kmsProviders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;bypassAutoEncryption&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why Ovianta Chose Manual Encryption
&lt;/h2&gt;

&lt;p&gt;Manual encryption provides us with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flexibility: By managing encryption directly in our code, we avoid dependencies on libraries incompatible with serverless environments.&lt;/li&gt;
&lt;li&gt;Granular control: We can tailor encryption to specific fields and workflows, ensuring efficiency and compliance. Although it is possible to achieve this behavior using schemas, that will force us to work on automatic mode that is not working in serverless environments such as Vercel.&lt;/li&gt;
&lt;li&gt;Portability: Since no special libraries are required, our encryption setup can be easily replicated across various environments.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How CSFLE Benefits Ovianta's Users
&lt;/h2&gt;

&lt;p&gt;For our customers—doctors and healthcare providers—CSFLE means:&lt;/p&gt;

&lt;p&gt;• Enhanced Privacy: Patient data is encrypted before leaving the client, ensuring it remains confidential even in the unlikely event of a breach. &lt;br&gt;
• Regulatory Compliance: By implementing advanced cryptographic measures, Ovianta adheres to stringent healthcare data protection standards, building trust with users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;At Ovianta, securing patient data is central to our mission of empowering healthcare providers with seamless, AI-driven workflows. MongoDB's CSFLE, particularly through manual encryption, allows us to achieve high levels of security while maintaining the flexibility needed for our serverless architecture.&lt;/p&gt;

&lt;p&gt;Whether you're building a healthcare app or managing sensitive user data, MongoDB's encryption options offer a reliable path to compliance and trust. For environments like ours, where automatic encryption isn't an option, manual encryption ensures robust security without compromise.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;p&gt;• MongoDB Documentation: &lt;a href="https://www.mongodb.com/docs/manual/core/csfle/fundamentals/automatic-encryption/" rel="noopener noreferrer"&gt;Automatic Encryption&lt;/a&gt; &lt;br&gt;
• MongoDB Documentation: &lt;a href="https://www.mongodb.com/docs/manual/core/csfle/fundamentals/manual-encryption/" rel="noopener noreferrer"&gt;Manual Encryption&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;At &lt;a href="https://ovinta.com" rel="noopener noreferrer"&gt;Ovianta&lt;/a&gt;, we're building a next-generation product for doctors to streamline software for their consultations using NextJS. Follow us on this journey to know more about how we're building.&lt;/p&gt;

</description>
      <category>cryptography</category>
      <category>mongodb</category>
    </item>
    <item>
      <title>Why the JavaScript ecosystem is so vibrant (and a bit chaotic) for a backend dev</title>
      <dc:creator>Rubén Martín Pozo</dc:creator>
      <pubDate>Wed, 30 Oct 2024 11:00:00 +0000</pubDate>
      <link>https://dev.to/ovianta/why-the-javascript-ecosystem-is-so-vibrant-and-a-bit-chaotic-for-a-backend-dev-oge</link>
      <guid>https://dev.to/ovianta/why-the-javascript-ecosystem-is-so-vibrant-and-a-bit-chaotic-for-a-backend-dev-oge</guid>
      <description>&lt;h3&gt;
  
  
  Why the JavaScript Ecosystem is So Vibrant (and a Bit Chaotic) for a Backend Dev
&lt;/h3&gt;

&lt;p&gt;As a backend developer with a background in Java and Spring Boot, stepping into the world of JavaScript felt like entering a parallel universe. JavaScript's ecosystem is dynamic, brimming with creativity, and driven by innovation. In contrast to Java, which is structured and stable, JavaScript thrives in a state of constant flux, fueled by new ideas and ever-evolving tools. For a backend developer used to a world of well-defined patterns and practices, the JavaScript world can feel like a bit of a wild ride, but that's what makes it so exciting.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. JavaScript: A Breath of Fresh Air for Backend Developers
&lt;/h3&gt;

&lt;p&gt;Coming from a Java and Spring Boot background, JavaScript was a bit of a shock to the system. Java offers reliability and structure. There's a defined way to approach most problems and a certain consistency in how frameworks evolve over time. JavaScript, on the other hand, feels like an open playground. In JavaScript, there are often multiple ways to approach a problem, and sometimes, no clear “right” way at all.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Contrast with Java&lt;/strong&gt;: Where Java feels familiar and consistent, JavaScript’s freedom opens up possibilities to experiment with new patterns and creative approaches.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptability&lt;/strong&gt;: JavaScript gives developers the flexibility to break free from traditional constraints, offering a range of tools and techniques that keep things fresh and exciting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JavaScript's flexibility isn’t just about syntax. It’s a mindset shift. The language encourages innovation and quick pivots, often leading developers to discover more efficient solutions than they might have imagined in a more rigid backend environment. This freedom allows for a sense of creativity that can be incredibly rewarding.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The Pros of a Fast-Moving Ecosystem
&lt;/h3&gt;

&lt;p&gt;One of the most fascinating aspects of JavaScript is the sheer speed at which it evolves. The ecosystem is a hub of innovation, with a steady stream of new libraries, frameworks, and tools being released and adopted by the community. JavaScript is in a constant state of reinvention, pushing the envelope to make development faster, easier, and more efficient. In contrast with Java, where everything needs to go through a heavier and more complex process to be adopted by users.  &lt;/p&gt;

&lt;p&gt;For a backend developer, this fast-moving ecosystem is a breath of fresh air. It means there's always something new to learn, whether it's a framework like React, Vue, or a server-side solution like Node.js. The community is constantly experimenting and finding better ways to solve common problems, pushing developers to stay up-to-date with the latest advancements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkk59h5zgb4np2z6p6tk1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkk59h5zgb4np2z6p6tk1.jpg" alt="Twp devs working on Javascript" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The Cons: Chaotic, Unstable, and Ever-Changing
&lt;/h3&gt;

&lt;p&gt;However, the pace of JavaScript's evolution also has its downsides. While Java's stability allows developers to build on a reliable foundation, JavaScript’s constant change can make it feel unstable. Frameworks and libraries rise and fall in popularity, sometimes within just a few months, making it challenging to commit to a particular stack or tool for long-term projects.&lt;/p&gt;

&lt;p&gt;Coming from a much more stable environment, it's difficult to understand what library or solution you should use to solve a particular problem, and that might increase your anxiety while trying out different approaches.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Constantly Changing Tools&lt;/strong&gt;: The fast pace of updates and new releases can make JavaScript feel like a moving target. Just when you've mastered one library or framework, a new version or a whole new approach might come along.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Steep Learning Curve for New Tools&lt;/strong&gt;: With so many options and regular updates, developers are always learning, which can be exhilarating but also overwhelming.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project Abandonment&lt;/strong&gt;: It’s not uncommon for tools or libraries to lose community support or be quickly abandoned, which can be risky for production projects that need long-term reliability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Documentation&lt;/strong&gt;: Frequently, the documentation is not as deep as I'm used to seeing in Java. That means more exploration and testing until you fully understand how the framework works. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JavaScript’s experimental nature means that while the ecosystem is highly innovative, it can also be unpredictable. Developers may invest time learning a specific tool only to find that it’s no longer relevant or actively supported. It’s a landscape where you need to stay flexible and be prepared to switch gears when necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. Why Embrace JavaScript’s Vibrancy?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Despite its challenges, JavaScript’s vibrant ecosystem has a lot to offer backend developers. It’s an environment that encourages a different kind of problem-solving, one that’s creative, flexible, and always evolving. Working in JavaScript has made me a more versatile developer. And also, the journey is a lot of fun!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Broader Career Opportunities&lt;/strong&gt;: JavaScript's popularity across both frontend and backend roles (thanks to frameworks like Node.js) creates career flexibility.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fresh Perspective on Development&lt;/strong&gt;: The experience of working in JavaScript provides new insights that can enhance backend development, encouraging a more agile, creative approach.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the end, the JavaScript ecosystem is a thrilling place to be. It’s unpredictable and sometimes chaotic, but for those who are willing to embrace the changes, it’s also incredibly rewarding. For a backend developer stepping into JavaScript, it’s a journey that promises to challenge, inspire, and expand your horizons—if you’re up for the ride.&lt;/p&gt;

&lt;p&gt;Note: Everything said here applies to TypeScript, too. In fact, it’s even wilder and more fun if you choose to go down the TypeScript path.&lt;/p&gt;




&lt;p&gt;At &lt;a href="https://ovianta.com" rel="noopener noreferrer"&gt;Ovianta&lt;/a&gt;, we're building a next-generation product for doctors to streamline software for their consultations using NextJS. Follow us on this journey to know more about how we're building.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>backend</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
