<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vivek Sharma on Medium]]></title>
        <description><![CDATA[Stories by Vivek Sharma on Medium]]></description>
        <link>https://medium.com/@vivekkumarsharma?source=rss-602099e84ad5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QfHf_-nUChAKh-9MGaO-2Q.jpeg</url>
            <title>Stories by Vivek Sharma on Medium</title>
            <link>https://medium.com/@vivekkumarsharma?source=rss-602099e84ad5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 01:03:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vivekkumarsharma/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Power of Thinking in Events: A New Perspective for Node.js & DevOps Engineers]]></title>
            <link>https://medium.com/@vivekkumarsharma/the-power-of-thinking-in-events-a-new-perspective-for-node-js-devops-engineers-95aa57968b6b?source=rss-602099e84ad5------2</link>
            <guid isPermaLink="false">https://medium.com/p/95aa57968b6b</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[cqrs-architecture]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[cqrs]]></category>
            <dc:creator><![CDATA[Vivek Sharma]]></dc:creator>
            <pubDate>Thu, 26 Jun 2025 16:19:27 GMT</pubDate>
            <atom:updated>2025-06-26T16:20:21.158Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYV15nF2pZkNzNZMp1CkrA.png" /></figure><p>As a developer immersed in <strong>Node.js</strong>, <strong>React</strong>, and <strong>DevOps</strong>, I’ve always enjoyed building scalable and reliable apps. But diving into <strong>Event Sourcing + CQRS</strong> reshaped how I think about state, history, and architecture.</p><p>If CRUD is a snapshot, <strong>event sourcing is a movie reel </strong>rich, replayable, and full of context.</p><h3>From State to Story: What is Event Sourcing?</h3><p>In a traditional app, you store the current state:</p><pre>{ &quot;orderId&quot;: 123, &quot;status&quot;: &quot;Shipped&quot; }</pre><p>But that doesn’t tell you <em>how</em> it got there.</p><p>With <strong>Event Sourcing</strong>, you store <strong>immutable events</strong>:</p><pre>[<br>  { &quot;event&quot;: &quot;OrderCreated&quot; },<br>  { &quot;event&quot;: &quot;ItemAdded&quot;, &quot;item&quot;: &quot;X&quot; },<br>  { &quot;event&quot;: &quot;OrderShipped&quot; }<br>]</pre><p>Your system becomes a ledger of what <strong>actually happened </strong>not just what <em>is</em>.</p><h3>CQRS: Let Commands Write and Queries Fly</h3><p><strong>CQRS</strong> separates:</p><ul><li><strong>Commands</strong>: Write-side logic (PlaceOrder, CancelItem)</li><li><strong>Queries</strong>: Read-side views (optimized projections, no joins)</li></ul><p>This split unlocks speed and flexibility:</p><ul><li>Read models optimized for GraphQL/REST</li><li>Write models enforce strong consistency</li><li>Easy to cache, shard, scale, and replicate</li></ul><h3>System Architecture</h3><p>Here’s a simplified version of what this architecture can look like:</p><h3>High-Level Architecture</h3><pre>[ React Frontend ]<br>                |<br>                v<br>        [ Command API (Node.js) ]  &lt;-- handles user intent (POST /createOrder)<br>                |<br>                v<br>        [ Event Store (SQLite, Kafka, DynamoDB) ]<br>                |<br>                +------------------+<br>                |                  |<br>          [Event Bus]        [Projector Service]<br>                |                  |<br>                v                  v<br>        [ Read DB (MongoDB, Redis, Elasticsearch) ]<br>                |<br>                v<br>        [ Query API (Fast, Read-Only)]</pre><h3>DevOps Workflow</h3><pre>GitHub → CI/CD → Docker Build → Deploy → Event-based Audit → Replay on Failure</pre><h3>Tech Stack</h3><ul><li><strong>Frontend:</strong> React, SWR, Tailwind CSS</li><li><strong>API (Write):</strong> Node.js (Express), TypeScript</li><li><strong>Event Store:</strong> SQLite / PostgreSQL / DynamoDB / Kafka</li><li><strong>Event Bus:</strong> Redis Streams, NATS, Kafka</li><li><strong>Read Models:</strong> Redis, MongoDB, Elasticsearch</li><li><strong>Projections:</strong> Node.js Workers, Temporal.io</li><li><strong>CI/CD:</strong> GitHub Actions, Azure Pipelines</li><li><strong>Infra:</strong> Docker, Kubernetes (optional), Terraform</li><li><strong>Monitoring:</strong> Loki, Prometheus, ELK Stack</li></ul><h3>Bonus: Plug GPT into Your Events</h3><p>Once your system logs everything as events, you can:</p><ul><li>Analyze patterns before user churn</li><li>Generate natural-language audit trails</li><li>Ask: <em>“Summarize user journey for ID 5562”</em></li></ul><p>This brings <strong>AI-native visibility</strong> into your infrastructure</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95aa57968b6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Cross-Platform Desktop Apps with React Native for Windows]]></title>
            <link>https://medium.com/@vivekkumarsharma/building-cross-platform-desktop-apps-with-react-native-for-windows-39107c38b4dd?source=rss-602099e84ad5------2</link>
            <guid isPermaLink="false">https://medium.com/p/39107c38b4dd</guid>
            <category><![CDATA[desktop-app]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactnativeappdevelopment]]></category>
            <dc:creator><![CDATA[Vivek Sharma]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 09:58:26 GMT</pubDate>
            <atom:updated>2025-06-10T10:03:36.588Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Et2X4DNZfAu9J1D7zI0gNQ.png" /></figure><p>React Native is best known for powering cross-platform mobile apps with a single codebase. But did you know that the same React Native experience can extend beyond iOS and Android to Windows desktops?</p><p><strong>React Native for Windows</strong> is an exciting project from Microsoft that brings the power of React Native to the Windows ecosystem, enabling you to build performant, native desktop apps using JavaScript and React.</p><h3>What Is React Native for Windows?</h3><p>React Native for Windows is a Microsoft-backed extension of the React Native framework that lets you create <strong>native Windows desktop applications</strong> using familiar web technologies.</p><p>Under the hood, it compiles to native Windows APIs, enabling access to OS-level features like file systems, notifications, camera, system tray integration, and more.</p><p>It supports:</p><ul><li><strong>Windows 10 &amp; 11</strong></li><li><strong>x86, x64, ARM</strong> architectures</li><li>Both <strong>Win32</strong> and <strong>UWP</strong> models</li></ul><p>This means whether you’re targeting tablets, laptops, or enterprise desktops, your app can run smoothly.</p><h3>Why Use React Native for Windows?</h3><p>If you already use React Native for mobile, expanding to Windows gives you:</p><ul><li><strong>Single Codebase</strong>: Share components and logic across mobile and desktop.</li><li><strong>Faster Time-to-Market</strong>: Reuse existing skills, libraries, and tooling.</li><li><strong>Access to Native APIs</strong>: Seamlessly integrate native Windows features with React Native modules.</li><li><strong>Modern UI</strong>: Build polished UIs with React-style components backed by Fluent Design.</li></ul><p>It’s also perfect for teams building <strong>internal tools</strong>, <strong>line-of-business apps</strong>, or <strong>cross-platform clients</strong> for services.</p><h3>Getting Started</h3><p>To build a React Native app for Windows, follow these steps:</p><h3>1. Set Up Prerequisites</h3><ul><li>Windows 10 or 11 (with developer mode enabled)</li><li>Visual Studio 2022 with <strong>UWP</strong>, <strong>Desktop Development with C++</strong>, and <strong>C++/CLI</strong> workloads</li><li>Node.js and Yarn or npm</li></ul><h3>2. Create Your App</h3><pre>npx react-native init MyWindowsApp<br>cd MyWindowsApp<br>npx react-native-windows-init --version latest --language cpp</pre><p>This adds a windows/ directory with all the necessary project files.</p><h3>3. Run Your App</h3><pre>npx react-native run-windows</pre><p>Your React Native app will launch as a native Windows desktop application.</p><h3>What Can You Build?</h3><p>Think beyond mobile. With React Native for Windows, you can create:</p><ul><li><strong>Productivity apps</strong> (dashboards, notetakers, editors)</li><li><strong>Internal enterprise tools</strong></li><li><strong>IoT management dashboards</strong></li><li><strong>Chat or collaboration apps</strong></li><li><strong>Cross-platform clients</strong> (Slack, Discord-like UIs)</li></ul><h3>Popular Companies Already Using It</h3><p>Several Microsoft tools (like <strong>Teams</strong>, <strong>Xbox apps</strong>, and <strong>Office integrations</strong>) have benefited from React Native for Windows. It shows the framework is mature enough for production at scale.</p><p>Open-source adopters and community modules continue to grow, improving support for features like:</p><ul><li>Accessibility</li><li>Keyboard/mouse support</li><li>Drag and drop</li><li>Multi-window capabilities</li></ul><h3>Limitations &amp; Considerations</h3><p>While powerful, React Native for Windows is still catching up with mobile in terms of ecosystem:</p><ul><li>Some React Native modules may lack Windows support</li><li>Setup can be heavier than mobile (requires Visual Studio and native builds)</li><li>Performance tuning may require knowledge of Windows internals or C++</li></ul><p>But for many use cases, especially enterprise or hybrid apps, the trade-offs are well worth it.</p><h3>Final Thoughts</h3><p>React Native for Windows opens a new frontier for React developers. With minimal changes, you can ship desktop apps that feel fast, native, and modern without abandoning the React ecosystem you already know and love.</p><p>As Microsoft continues investing in the project, now is a great time to explore it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39107c38b4dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CVE-2025–29927 A Deep Dive into the Alarming Next.js Middleware Vulnerability]]></title>
            <link>https://medium.com/@vivekkumarsharma/cve-2025-29927-a-deep-dive-into-the-alarming-next-js-middleware-vulnerability-683559f8fcb1?source=rss-602099e84ad5------2</link>
            <guid isPermaLink="false">https://medium.com/p/683559f8fcb1</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[middleware]]></category>
            <dc:creator><![CDATA[Vivek Sharma]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 09:43:50 GMT</pubDate>
            <atom:updated>2025-06-10T09:43:50.632Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zWfruFeh9vNKFuhJHdTjUw.png" /></figure><p>When a security flaw hits a widely adopted framework like Next.js, it can put thousands of websites at risk almost instantly. That’s exactly what we’re seeing with <strong>CVE-2025–29927</strong>, a newly discovered vulnerability affecting multiple versions of Next.js, the React-based framework trusted by developers around the world.</p><p>Let’s unpack this issue, understand how it works, and see what you need to do to protect your apps.</p><h3>The Flaw That Breaks the Guardrails</h3><p>Think of Next.js middleware as a security guard stationed before every page of your app validating users, blocking unwanted visitors, and enforcing headers like CSP. This middleware is often the first line of defense.</p><p>But what if an attacker could walk right past it, simply by whispering a special phrase?</p><p>That’s the danger here. By crafting an HTTP header like:</p><pre>x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware</pre><p>the attacker can convince Next.js to <em>skip all middleware execution entirely</em>. No login checks. No IP restrictions. No headers. It’s like shutting off the alarm system before walking through the front door.</p><h3>A Quick Primer on Next.js Middleware</h3><p>Next.js middleware runs before page rendering. It’s used to:</p><ul><li>Check if a user is authenticated</li><li>Restrict content by geography</li><li>Set security headers</li><li>Perform redirects and rewrites</li></ul><p>In many projects, it’s tightly coupled with application security. That’s why this vulnerability is especially dangerous.</p><h3>Why This Bug Exists</h3><p>To avoid infinite recursion in middleware, Next.js uses a counter stored in the x-middleware-subrequest header. Each time middleware executes, it checks this header:</p><pre>const subrequests = request.headers.get(&#39;x-middleware-subrequest&#39;)?.split(&#39;:&#39;) || [];<br>const depth = subrequests.filter(s =&gt; s === middlewareName).length;</pre><pre>if (depth &gt;= MAX_RECURSION_DEPTH) {<br>  return NextResponse.next(); // Skips the middleware<br>}</pre><p>Problem is, <strong>this header can be spoofed by anyone</strong>.</p><p>If the attacker includes five repeated entries of the middleware’s name, Next.js assumes it’s run too many times and silently disables it.</p><h3>Testing Your Application</h3><p>You can test your application using the <a href="https://github.com/strobes-security/nextjs-vulnerable-app">official vulnerable app</a>:</p><pre>git clone https://github.com/strobes-security/nextjs-vulnerable-app<br>cd nextjs-vulnerable-app<br>npm install &amp;&amp; npm run dev</pre><p>Try this cURL command:</p><pre>curl -v -H &quot;x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware&quot; http://localhost:3000/dashboard</pre><p>If the page loads without login, your app is vulnerable.</p><h3>Different Projects, Different Attack Strings</h3><p>Depending on your Next.js version and file structure, the exploit string changes:</p><ul><li><strong>Pages Router (v11.1.4–12.1.x):</strong></li><li>x-middleware-subrequest: pages/_middleware</li><li><strong>App Router (v12.2.x — 13.x):</strong></li><li>x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware</li><li><strong>App Router with </strong><strong>/src folder (v14.x - 15.2.2):</strong></li><li>x-middleware-subrequest: src/middleware:src/middleware:src/middleware:src/middleware:src/middleware</li></ul><h3>Real-World Impact</h3><p>This is not just theoretical it has serious implications:</p><ul><li><strong>Bypass Authentication:</strong> Admin panels, user dashboards completely exposed.</li><li><strong>Remove CSP Protections:</strong> Makes apps vulnerable to XSS.</li><li><strong>Ignore Geo Restrictions:</strong> Content meant for specific regions can be accessed worldwide.</li></ul><p>Here’s an example of bypassing login and CSP:</p><pre>curl -H &quot;x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware&quot; \<br>     -H &quot;Content-Type: text/html&quot; \<br>     --data &quot;&lt;script&gt;alert(&#39;hacked&#39;)&lt;/script&gt;&quot; \<br>     http://example.com/protected</pre><h3>How to Fix It</h3><p><strong>✅ Update Now:</strong><br> Upgrade to <strong>Next.js v15.2.3+</strong> or <strong>v14.2.25+</strong>. These versions patch the vulnerability.</p><p><strong>🔐 Block the Header (Temporary Fix):</strong><br> If you can’t update right away:</p><ul><li><strong>NGINX:</strong></li><li>location / { proxy_set_header x-middleware-subrequest &quot;&quot;; }</li><li><strong>Apache:</strong></li><li>RequestHeader unset x-middleware-subrequest</li></ul><p><strong>🛡 Implement Defense-in-Depth:</strong></p><ul><li>Never rely on middleware <em>alone</em> for security.</li><li>Use server-side checks (e.g., getServerSideProps or NextAuth.js).</li><li>Add verification in API routes.</li></ul><h3>Key Takeaways</h3><p>This bug is a reminder of a few fundamental truths in security:</p><ol><li><strong>Never Trust Client Input</strong> — Headers can be forged.</li><li><strong>Simple Bugs Have Huge Impacts</strong> — A basic counter check led to widespread compromise.</li><li><strong>Security Must Be Layered</strong> — Middleware isn’t a catch-all. Defense needs to exist at every layer.</li></ol><h3>Stay Vigilant, Stay Secure</h3><p>Even well-maintained frameworks like Next.js can harbor critical bugs. The key is to:</p><ul><li>Keep your dependencies up to date</li><li>Regularly audit your app</li><li>Implement layered security</li></ul><p>The fix for CVE-2025–29927 is simple but only if you act.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=683559f8fcb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a TypeScript SDK for My .NET Core API — From Swagger to NPM]]></title>
            <link>https://medium.com/@vivekkumarsharma/building-a-typescript-sdk-for-my-net-core-api-from-swagger-to-npm-0d1d1b3f9ae7?source=rss-602099e84ad5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d1d1b3f9ae7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[npm-registry]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[open-api]]></category>
            <dc:creator><![CDATA[Vivek Sharma]]></dc:creator>
            <pubDate>Fri, 06 Jun 2025 09:26:37 GMT</pubDate>
            <atom:updated>2025-06-06T09:26:37.345Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a TypeScript SDK for My .NET Core API — From Swagger to NPM</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KPE0PR4I4-muSoG9hQIu3g.png" /></figure><p>As a full-stack developer working on enterprise-grade APIs, I’ve often seen how challenging it can be for consumers to integrate with backend services. Whether it’s frontend teams within the organization or external partners, they typically spend a considerable amount of time:</p><ul><li>Deciphering endpoint behavior</li><li>Rewriting request logic</li><li>Manually handling tokens</li><li>Dealing with inconsistent error formats</li></ul><p>I’m currently working on a project where we’ve built a robust .NET Core API platform. During the engagement, my client specifically requested that I create a JavaScript/TypeScript SDK that could be bundled as an NPM package. Their goal was to distribute it to their customers so integration could be seamless, consistent, and scalable. That request sparked this entire SDK development journey.</p><h3>🎯 What I Set Out to Build</h3><p>The goal was to create a <strong>TypeScript-based SDK</strong> that would:</p><ul><li>Expose clean methods like login(), getRecords(), and createEntity()</li><li>Internally manage base URLs and token injection</li><li>Handle filtering, pagination, and uploads where required</li><li>Be distributed as an NPM package</li><li>Offer auto-generated, browsable documentation</li></ul><h3>🛠️ Tools and Technologies Used</h3><p>To build this SDK, I relied on:</p><ul><li><strong>TypeScript</strong> — For type safety and IDE support</li><li><strong>Axios</strong> — To manage HTTP requests and interceptors</li><li><strong>tsup</strong> — For bundling the SDK in CommonJS and ESM formats</li><li><strong>typedoc</strong> — For generating documentation from code comments</li><li><strong>NPM</strong> — To publish and version the SDK</li></ul><h3>📁 Project Structure</h3><p>The SDK was structured in a modular way to keep code maintainable:</p><pre>src/<br>├── config.ts         // Axios setup and interceptors<br>├── auth.ts           // Login method<br>├── resource.ts       // Sample domain logic<br>├── index.ts          // Export entry point</pre><h3>⚙️ Axios Setup and Shared Configuration</h3><p>I configured a centralized Axios instance that handles:</p><ul><li>Setting the base URL</li><li>Injecting Bearer tokens</li><li>Catching and transforming API errors</li></ul><p>This ensured every endpoint behaved consistently and followed the same contract especially where it was required to normalize responses.</p><h3>📦 Abstracting the API</h3><p>Rather than exposing raw URLs or HTTP methods, the SDK provides:</p><ul><li>Simplified methods like getResourceById(id)</li><li>Wrapper functions that manage parameters and request shape</li><li>Hidden internal logic for headers and response parsing</li></ul><p>This means consumers interact with familiar, domain-centric methods without worrying about the underlying paths or protocols.</p><h3>📚 Developer Documentation with TypeDoc</h3><p>Documentation is often overlooked, but not here. I added structured JSDoc-style comments to every method and interface. Then, using typedoc, I generated:</p><ul><li>HTML-based docs</li><li>Searchable method references</li><li>Easy-to-share developer help guides</li></ul><p>This improved onboarding and reduced dependency on external support, especially in partner environments.</p><h3>🚀 Publishing to NPM</h3><p>With the build process handled by tsup, I was able to:</p><ul><li>Generate both .cjs and .mjs outputs</li><li>Include TypeScript definitions</li><li>Define proper exports in package.json</li></ul><p>Once published, any consumer could install the SDK using:</p><pre>npm install my-api-sdk</pre><p>And start using it immediately in their frontend or backend project.</p><h3>💡 Key Benefits of the SDK</h3><p>By introducing this SDK, we achieved:</p><ul><li><strong>Code reuse across teams</strong></li><li><strong>Fewer bugs due to type safety</strong></li><li><strong>Faster integration times</strong></li><li><strong>Cleaner separation of concerns</strong></li><li><strong>A unified, version-controlled client library</strong></li></ul><h3>🧠 Lessons Learned</h3><p>Throughout this process, I discovered a few important takeaways:</p><ul><li><strong>Swagger is a powerful starting point</strong> — always leverage it for consistency.</li><li><strong>A typed SDK is not a luxury</strong> — it’s a productivity tool that scales with your API.</li><li><strong>Documentation matters</strong> — especially when distributing to external consumers.</li><li><strong>A little abstraction goes a long way</strong> — it creates confidence and reduces friction.</li><li><strong>Add features only where required</strong> — not everything needs to be over-engineered.</li></ul><h3>🔮 What’s Next</h3><p>In future iterations of the SDK, I plan to:</p><ul><li>Add more modules for other API resources</li><li>Introduce retry logic and rate limiting</li><li>Improve error typing and response models</li><li>Automate versioning and publishing using GitHub Actions</li><li>Explore openAPI generator integration where required</li></ul><h3>🏁 Final Thoughts</h3><p>This SDK wasn’t just a passion project it was a client requirement. And it turned out to be one of the most useful additions to the API ecosystem. By packaging complex functionality into clean, reusable methods, we made our API platform more accessible, more reliable, and ultimately more valuable.</p><p>If you’re working on a .NET Core API or any backend that serves multiple consumers, building a TypeScript SDK might be the smartest and most future-ready investment you can make. You won’t just be writing code you’ll be creating a foundation for better collaboration, smoother integration, and faster delivery.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d1d1b3f9ae7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Strengthening Data Privacy with Always Encrypted and Azure Key Vault in SQL Server]]></title>
            <link>https://medium.com/@vivekkumarsharma/strengthening-data-privacy-with-always-encrypted-and-azure-key-vault-in-sql-server-2d000949a6b8?source=rss-602099e84ad5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d000949a6b8</guid>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[azure-key-vault]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[data-security]]></category>
            <dc:creator><![CDATA[Vivek Sharma]]></dc:creator>
            <pubDate>Wed, 04 Jun 2025 11:43:46 GMT</pubDate>
            <atom:updated>2025-06-04T11:43:46.543Z</atom:updated>
            <content:encoded><![CDATA[<p>In a time where data breaches and privacy regulations are front and center, implementing encryption at the database level is no longer optional it’s essential. Recently, I took on the challenge of upgrading our application’s data security by adopting <strong>Always Encrypted</strong> in SQL Server and integrating it with <strong>Azure Key Vault</strong> for key management. Here’s a deep dive into how we achieved this and the lessons learned along the way.</p><h3>🔍 The Problem</h3><p>We were storing sensitive information like emails, contact details, and identifiers in plain text within SQL Server. Though access was tightly controlled, this still posed a risk especially in shared environments, backups, or during DBA-level access.</p><p>The goal was clear: <strong>encrypt specific columns</strong> without rewriting all our application logic or disrupting existing Entity Framework usage.</p><h3>🧩 The Chosen Approach: Always Encrypted with Azure Key Vault</h3><p>After evaluating several options including symmetric AES encryption with custom logic and SQL Server TDE we concluded that <strong>Always Encrypted</strong> was the most robust, future-proof, and transparent choice.</p><p>✅ Minimal impact on existing Entity Framework queries</p><p>✅ Seamless integration with Azure Key Vault</p><p>✅ Transparent encryption/decryption from the application layer</p><p>✅ SQL Server ensures sensitive data is never seen in plaintext by DBAs or in logs</p><h3>🛠️ Implementation Overview</h3><ol><li><strong>Resized Columns</strong>: Encrypted values are longer. We doubled/tripled the size of NVARCHAR fields across multiple tables.</li><li><strong>Azure Key Vault Setup</strong>: We created a new RSA key, assigned our SQL Server’s managed identity with the <em>Key Vault Crypto User</em> role.</li><li><strong>Column Master Key and Encryption Key</strong>: Defined using Azure Key Vault as the provider and linked via SQL DDL scripts.</li><li><strong>Updated Application</strong>:</li></ol><ul><li>Added Column Encryption Setting=Enabled in the connection string.</li><li>Used Microsoft.Data.SqlClient with AzureKeyVaultProvider.</li><li>Registered the Key Vault provider in our startup service.</li></ul><h3>🧪 Challenges Faced</h3><ul><li>⚠️ Initial failures due to missing provider registration</li><li>🔑 RBAC propagation delay caused temporary access issues</li><li>🧵 EF Core integration required using raw ADO.NET in some cases to handle encrypted reads</li><li>🕵️‍♂️ Decryption failures due to incorrect connection string setup</li></ul><blockquote><strong><em>Tip</em></strong><em>: Always validate the connection string with </em><em>Encrypt=True;TrustServerCertificate=False;Column Encryption Setting=Enabled;</em></blockquote><h3>🧾 The Tables We Modified</h3><p>To prepare for encryption, we resized columns storing PII:</p><h4>🗂 Client Table</h4><ul><li>contactEmail, contactPhone, contactPerson → NVARCHAR(512/150)</li></ul><h4>🗂 Customer Table</h4><ul><li>accessCode, accountExecutive, accountManager, contactName → NVARCHAR(512)</li></ul><p>…and similarly for Contact, Requestor, Address, and Consumer tables.</p><h3>🔐 Results and Benefits</h3><p>✅ Encryption is now <strong>transparent</strong> to application users.<br>✅ DBAs or unauthorized reads see <strong>ciphertext only</strong>.<br>✅ We are <strong>future-proofed</strong> for compliance with data privacy laws (like GDPR, HIPAA).</p><h3>💬 Final Thoughts</h3><p>Data encryption should never be an afterthought. With Azure Key Vault and Always Encrypted, we were able to <strong>implement enterprise-grade protection</strong> without rewriting business logic or workflows.</p><p>If you’re considering this route, make sure:</p><ul><li>You correctly configure RBAC and provider registration.</li><li>Your application uses the <strong>Microsoft.Data.SqlClient</strong> driver (not System.Data.SqlClient).</li><li>You resize your columns <strong>before</strong> encrypting them.</li></ul><p>🧑‍💻 Happy to share more about this journey — let me know in the comments if you’re exploring something similar!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d000949a6b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>