<?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 Trivikram V on Medium]]></title>
        <description><![CDATA[Stories by Trivikram V on Medium]]></description>
        <link>https://medium.com/@trivikramv?source=rss-1be6a927808f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YiZzrcWbIji0rE5-</url>
            <title>Stories by Trivikram V on Medium</title>
            <link>https://medium.com/@trivikramv?source=rss-1be6a927808f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:58:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@trivikramv/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[Istio mTLS Explained: Securing Service-to-Service Traffic in Kubernetes]]></title>
            <link>https://medium.com/@trivikramv/istio-mtls-explained-securing-service-to-service-traffic-in-kubernetes-c3d850dfd9b2?source=rss-1be6a927808f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3d850dfd9b2</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Trivikram V]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 07:40:56 GMT</pubDate>
            <atom:updated>2026-01-13T07:40:56.846Z</atom:updated>
            <content:encoded><![CDATA[<p>Kubernetes makes scaling micro-services easy, but it also flattens the network. By default, any pod can talk to any other pod, and in a multi-tenant cluster that’s a serious security problem.</p><p>As your system grows, simple questions become hard: <em>How does one service prove who it is? How do you encrypt traffic inside the cluster? And how do you manage certificates without turning security into an operational nightmare?</em></p><p>This are exactly the problems Istio and mutual TLS (mTLS) are designed to solve.</p><h3>What Is Istio and Why Use It?</h3><p><a href="https://istio.io/latest/docs/overview/what-is-istio/">Istio</a> is a service mesh that introduces a <strong>dedicated networking layer</strong> for service-to-service communication in Kubernetes.</p><p>Instead of embedding concerns like encryption, retries, and observability into application code, Istio injects a lightweight <strong>Envoy sidecar proxy</strong> into each pod. This proxy transparently intercepts all inbound and outbound traffic.</p><p>From the application’s perspective, it’s just sending plain HTTP requests.<br>Behind the scenes, Istio upgrades that traffic to <strong>encrypted, authenticated mTLS connections</strong> and applies security policies automatically.</p><h3>What Is mTLS?</h3><p>Standard TLS (like when you visit a website) only verifies the server’s identity. <br><strong>Mutual TLS (mTLS)</strong> goes one step further: <strong>both sides must prove who they are</strong>.</p><ul><li>The server verifies the client’s certificate</li><li>The client verifies the server’s certificate</li><li>Once trust is established, the connection is encrypted</li></ul><p>Unlike regular TLS (one-way trust), mTLS ensures that only trusted workloads can talk to each other and that traffic cannot be sniffed or tampered with.</p><h3>How Istio Automates Identity &amp; Certificates</h3><p>Manually managing certificates at scale is not realistic. Istio avoids that entirely by automating the Public Key Infrastructure (<a href="https://www.geeksforgeeks.org/computer-networks/public-key-infrastructure/">PKI</a>) lifecycle:</p><ul><li><strong>Identity:</strong> Every pod receives a unique cryptographic identity (<a href="https://spiffe.io/docs/latest/spiffe-about/spiffe-concepts/">SPIFFE ID</a>) derived from its Kubernetes Service Account</li><li><strong>Short-lived certificates:</strong> Workload certificates expire quickly (typically 24 hours)</li><li><strong>Automatic rotation:</strong> Istio rotates certificates proactively (around every 12 hours)</li><li><strong>Limited blast radius:</strong> Even if a certificate is compromised, it’s valid only for a short window</li></ul><p>Security improves, while operational overhead stays low.</p><h3>The Architecture: How Traffic Flows</h3><p>Understanding how mTLS is enforced is easier with a visual.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LyQjFBVBxfBdzq78b2JOCg.png" /></figure><blockquote><strong>PeerAuthentication (PeerAuth) </strong>is the Istio policy that defines whether a service/namespace - requires mTLS (STRICT), allows both mTLS and plain text traffic (PERMISSIVE), or disables mTLS altogether.</blockquote><p>In the diagram above, we have three distinct environments interacting:</p><ol><li><strong>Frontend &amp; Backend:</strong> Managed by Istio with STRICT security.</li><li><strong>Namespace2:</strong> Managed by Istio but in PERMISSIVE mode.</li><li><strong>Namespace1:</strong> A legacy environment with no Istio sidecars.</li></ol><p>Let’s break down the traffic flows shown in the Green and Red lines.</p><h3>1. The Secure Core (Green Lines)</h3><p>When <strong>Pod-1 (Frontend)</strong> talks to <strong>Pod-2 (Backend)</strong>, both pods have Envoy sidecars.</p><ul><li>Istio detects both sides are in the mesh.</li><li>It automatically upgrades the connection to mTLS.</li><li><strong>Result:</strong> Traffic is allowed and encrypted.</li></ul><h3>2. The “Permissive” Bridge (Green Lines)</h3><p>Look at <strong>Namespace2</strong>. It is set to PERMISSIVE mode. This is a special mode designed for migrations.</p><ul><li><strong>From Frontend:</strong> When the Frontend calls Namespace2, it uses mTLS because it knows a sidecar is present.</li><li><strong>From Legacy (Pod-3):</strong> When the non-Istio Pod-3 calls Namespace2, it sends <strong>Plain Text</strong>.</li><li><strong>Result:</strong> The proxy in Namespace2 accepts <em>both</em>. It is a bridge between the old world and the new world.</li></ul><h3>3. The Denied Traffic (Red Lines)</h3><p>This is where the security value of Istio becomes obvious.</p><ul><li><strong>Legacy (Pod-3) → Backend:</strong> The Backend is in STRICT mode. It requires a valid client certificate.</li><li><strong>Legacy (Pod-3) → Frontend:</strong> The Frontend is in STRICT mode.</li><li><strong>Result:</strong> Since Pod-3 cannot present a certificate, the connection is <strong>rejected</strong> by the sidecar. The traffic never even reaches the application container.</li></ul><h3>Why This Matters</h3><p>This architecture enforces a <strong>zero-trust model inside the cluster</strong>.</p><p>In a standard Kubernetes cluster, a compromised Pod (Pod-3) can often move laterally and access sensitive services. With Istio mTLS in STRICT mode, that path is closed. Even if an attacker gains access to a pod, they cannot communicate with critical services unless they possess a valid, Istio-issued identity.</p><p>Security is enforced consistently, transparently, and by default.</p><h3>A Practical Note on Rolling This Out</h3><p>Most teams don’t enable STRICT mTLS everywhere on day one.</p><p>A common approach is to start with PERMISSIVE<strong> </strong>mode, allowing encrypted and plain text traffic to coexist while services are gradually onboarded to the mesh. Once all workloads have sidecars and identities, switching to STRICT becomes a controlled security upgrade rather than a breaking change.</p><p>If something stops working after enabling STRICT mTLS, the cause is usually simple:<br><strong>the caller doesn’t have an Istio identity</strong>.</p><p>mTLS failures are not network problems, they’re identity problems.</p><h3>Final Thoughts</h3><p>Istio mTLS brings zero-trust networking to Kubernetes <strong>without forcing application developers to become security experts</strong>.</p><p>By offloading identity, encryption, and certificate management to the platform, you ensure that security scales naturally as your cluster grows quietly, consistently, and by default.</p><h3>Further Reading</h3><ul><li><strong>Istio Overview — </strong><a href="https://istio.io/">https://istio.io/</a></li><li><strong>Istio Security Overview </strong>— <a href="https://istio.io/latest/docs/concepts/security/">https://istio.io/latest/docs/concepts/security/</a></li><li><strong>PeerAuthentication Policy</strong> — <a href="https://istio.io/latest/docs/reference/config/security/peer_authentication/">https://istio.io/latest/docs/reference/config/security/peer_authentication</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3d850dfd9b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Access Control in Azure DevOps: Streamlining Permissions Configuration through APIs]]></title>
            <link>https://medium.com/@trivikramv/access-control-in-azure-devops-streamlining-permissions-configuration-through-apis-5f0feb9e5c8f?source=rss-1be6a927808f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f0feb9e5c8f</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[azure-devops-services]]></category>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[access-control]]></category>
            <category><![CDATA[access-control-list]]></category>
            <dc:creator><![CDATA[Trivikram V]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 17:37:25 GMT</pubDate>
            <atom:updated>2026-01-06T17:37:25.472Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*zPHEMf3X1gfDYnHm_2kHaQ.png" /></figure><p>Azure DevOps is a comprehensive set of tools provided by Microsoft for collaborative software development. It includes a range of features including Version Control, Agile Planning, Artifacts management, Build Automation, and Release management, all seamlessly integrated to support the DevOps lifecycle.</p><h3>Understanding Access Control in Azure DevOps</h3><p>Azure DevOps is a powerful platform, just like with any powerful tool, Security is paramount. Access control ensures the right people have access to the right resources, keeping your project secure and on track.</p><p>Access control in Azure DevOps acts as a gatekeeper, which relies on a system of Security Namespaces, Access Control Lists (ACLs), and Entries(ACEs) to define granular permissions.</p><p>Here’s a simplified breakdown:</p><ul><li><strong>Security Namespaces:</strong> Think of these as security zones for different resource families, like Work items or Git repositories. Each family has its security namespace.</li><li><strong>Access Control Lists (ACLs):</strong> These lists reside within security namespaces and contain the access rules, tokens, and Access Control Entries (ACEs) for resources.</li><li><strong>Access Control Entries (ACEs):</strong> Each Entry specifies who can do what (allow/deny permission) on a specific resource (represented by a token).</li><li><strong>Tokens: </strong>They act as unique identifiers for resources, with a common hierarchy and separator format across different resource types.</li></ul><p>By effectively configuring access control, you can ensure your development environment remains secure and efficient.</p><h3>Managing Access Control Entries with APIs</h3><p>While the Azure DevOps UI offers a user-friendly way to manage access control. For complex setups or ongoing maintenance, APIs provide a powerful and automated solution. APIs allow you to programmatically interact with Azure DevOps, streamlining permission management and integrating it with your development workflows.</p><h3>Example: Granting Git Repository Permissions to a Group via API</h3><p>Let’s consider an example of how we can leverage an API to grant a specific group (developers) <strong>Contribute</strong> permission to all Git repositories and/or a specific Git repository as well. This is just an example, and APIs can be used to manage a wide range of access control scenarios in Azure DevOps.</p><p>Here’s a high-level overview of the steps involved:</p><ol><li><strong>Authentication:</strong> First you’ll need a Credential or Token. This can be done using a Personal Access Token (PAT) with the appropriate permissions (e.g., “Manage security”).</li><li><strong>Identify Resources:</strong> Determine the IDs for the resource Git repository and the group (developers). You can retrieve these IDs using dedicated API calls.</li><li><strong>Construct the API Request:</strong> Build a request to the Access Control API endpoint. This request will specify the desired action (granting <strong>Contribute</strong> permissions), the target repository ID, the token, and any additional configuration options.</li></ol><p>In the next section, we’ll look into the code example.</p><h3>Security Namespace ID:</h3><p>To interact with access control using API, we first need to determine the ID of the security namespace for our desired action (e.g., Git repositories).</p><p>The following API call retrieves a list of all security namespaces. We can then filter the results to identify the security namespace specifically associated with Git repositories:</p><pre>GET<br>https://dev.azure.com/{organization}/_apis/securitynamespaces?api-version=7.1-preview.1 -Headers @{Authorization=(&quot;Basic {0}&quot; -f $base64AuthInfo)}</pre><p>Remember to replace <strong>dev.azure.com </strong>with your Azure DevOps domain name, <strong>{organization}</strong> with the actual organization name in your code example and the <strong>base64AuthInfo</strong> is nothing but the <strong>PAT Token</strong> encrypted in base64 format.</p><p>Sample Response:</p><pre>{<br>  &quot;count&quot;: 10,<br>  &quot;value&quot;: [<br>    {<br>      &quot;namespaceId&quot;: &quot;445d2788-c5fb-4132-bbef-09c4045ad93f&quot;,<br>      &quot;name&quot;: &quot;WorkItemTrackingAdministration&quot;,<br>      &quot;displayName&quot;: &quot;WorkItemTrackingAdministration&quot;,<br>      &quot;separatorValue&quot;: &quot;\u0000&quot;,<br>      &quot;elementLength&quot;: -1,<br>      &quot;writePermission&quot;: 1,<br>      &quot;readPermission&quot;: 0,<br>      &quot;dataspaceCategory&quot;: &quot;WorkItem&quot;,<br>      &quot;actions&quot;: [<br>        {<br>          &quot;bit&quot;: 1,<br>          &quot;name&quot;: &quot;ManagePermissions&quot;,<br>          &quot;displayName&quot;: &quot;Manage permissions&quot;,<br>          &quot;namespaceId&quot;: &quot;445d2788-c5fb-4132-bbef-09c4045ad93f&quot;<br>        },<br>        {<br>          &quot;bit&quot;: 2,<br>          &quot;name&quot;: &quot;DestroyAttachments&quot;,<br>          &quot;displayName&quot;: &quot;Destroy attachments&quot;,<br>          &quot;namespaceId&quot;: &quot;445d2788-c5fb-4132-bbef-09c4045ad93f&quot;<br>        }<br>      ],<br>      &quot;structureValue&quot;: 0,<br>      &quot;extensionType&quot;: null,<br>      &quot;isRemotable&quot;: false,<br>      &quot;useTokenTranslator&quot;: false<br>    },<br>    {...}<br>  ]<br>}</pre><h3>Token:</h3><p>In the previous step, we retrieved the security namespace ID. Now, we need to identify the specific resource within that security namespace on which we want to modify permissions (e.g., a specific Git repository).</p><p>The general structure of a token for project-level permissions for Git starts with “repoV2/” followed by the project ID. This project ID identifies the specific Azure DevOps project within your organization.</p><p><strong>Retrieving Project ID:</strong></p><p>You can retrieve a list of all projects within your organization using the following API call:</p><pre>GET<br>https://dev.azure.com/{organization}/_apis/projects?api-version=7.1-preview.4</pre><p>Replace dev.azure.com with your Azure DevOps domain name, <strong>{organization}</strong> with your organization name, and add the <strong>Authentication</strong> headers.</p><p>Sample Response:</p><pre>{<br>  &quot;count&quot;: 2,<br>  &quot;value&quot;: [<br>    {<br>      &quot;id&quot;: &quot;eb6e4656-77fc-42a1-9181-4c6d8e9da5d1&quot;,<br>      &quot;name&quot;: &quot;Project-1&quot;,<br>      &quot;description&quot;: &quot;Team Foundation&quot;,<br>      &quot;url&quot;: &quot;https://dev.azure.com/{org}/_apis/projects/eb6e4656-77fc-42a1-9181-4c6d8e9da5d1&quot;,<br>      &quot;state&quot;: &quot;wellFormed&quot;<br>    },<br>    {<br>      &quot;id&quot;: &quot;6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c&quot;,<br>      &quot;name&quot;: &quot;Project-2&quot;,<br>      &quot;description&quot;: &quot;Git projects&quot;,<br>      &quot;url&quot;: &quot;https://dev.azure.com/{org}/_apis/projects/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c&quot;,<br>      &quot;state&quot;: &quot;wellFormed&quot;<br>    }<br>  ]<br>}</pre><p><strong>Building the Token:</strong></p><p>Once you have the project ID, you can construct the token format for project-level permissions:</p><pre>repoV2/{PROJECT_ID}</pre><p>If you want to modify permissions for a <strong>specific repository</strong> within a project, you’ll need to include its ID in the token:</p><pre>repoV2/{PROJECT_ID}/{REPOSITORY_ID}</pre><p>The <strong>{REPOSITORY_ID}</strong> can be found in the Azure DevOps UI by navigating to the desired repository and inspecting its URL. The ID typically appears after the project name and slash (/) in the URL.</p><h3>Specifying Permissions: Allow vs Deny</h3><p>Now that we have identified the target resource (through the token), we need to define the specific permissions we want to grant or deny to the group. Azure DevOps uses a <strong>Bitmask</strong> system to represent permissions, where each bit corresponds to a specific permission.</p><p><strong>Retrieving Bit Identifiers:</strong></p><p>While directly retrieving the bit identifiers might not be ideal, you can find them using the Azure DevOps API:</p><pre>GET<br>https://dev.azure.com/{organization}/_apis/securitynamespaces/{security-namespace-id}?api-version=7.1</pre><p>Replace<strong> dev.azure.com </strong>with your Azure DevOps domain name,<strong> {organization}</strong> with your organization name, <strong>{security-namespace-id}</strong> with the ID retrieved earlier, and add the <strong>Authentication</strong> headers. This API call will return a list of permissions along with their corresponding bit identifiers.</p><p>Sample Response:</p><pre>{<br>  &quot;count&quot;: 10,<br>  &quot;value&quot;: [<br>    {...},<br>    {<br>      &quot;namespaceId&quot;: &quot;2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87&quot;,<br>      &quot;name&quot;: &quot;Git Repositories&quot;,<br>      &quot;displayName&quot;: &quot;Git Repositories&quot;,<br>      &quot;separatorValue&quot;: &quot;/&quot;,<br>      &quot;elementLength&quot;: -1,<br>      &quot;writePermission&quot;: 8192,<br>      &quot;readPermission&quot;: 2,<br>      &quot;dataspaceCategory&quot;: &quot;Git&quot;,<br>      &quot;actions&quot;: [<br>        {<br>          &quot;bit&quot;: 1,<br>          &quot;name&quot;: &quot;Administer&quot;,<br>          &quot;displayName&quot;: &quot;Administer&quot;,<br>          &quot;namespaceId&quot;: &quot;2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87&quot;<br>        },<br>        {<br>          &quot;bit&quot;: 2,<br>          &quot;name&quot;: &quot;GenericRead&quot;,<br>          &quot;displayName&quot;: &quot;Read&quot;,<br>          &quot;namespaceId&quot;: &quot;2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87&quot;<br>        },<br>        {<br>          &quot;bit&quot;: 4,<br>          &quot;name&quot;: &quot;GenericContribute&quot;,<br>          &quot;displayName&quot;: &quot;Contribute&quot;,<br>          &quot;namespaceId&quot;: &quot;2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87&quot;<br>        },<br>        {<br>          &quot;bit&quot;: 8,<br>          &quot;name&quot;: &quot;ForcePush&quot;,<br>          &quot;displayName&quot;: &quot;Force push&quot;,<br>          &quot;namespaceId&quot;: &quot;2e9eb7ed-3c0a-47d4-87c1-0ffdd275fd87&quot;<br>        },<br>        {...}<br>      ],<br>      &quot;structureValue&quot;: 1,<br>      &quot;extensionType&quot;: null,<br>      &quot;isRemotable&quot;: true,<br>      &quot;useTokenTranslator&quot;: false<br>    }<br>  ]<br>}</pre><p>Example Permissions:</p><ul><li><strong>Force Push:</strong> Allows rewriting history, and deleting branches, and tags. This permission requires setting the “<strong>allow</strong>” bit to <strong>8</strong>.</li><li><strong>Contribute:</strong> Allows creating and pushing code changes. To deny this permission, set the “<strong>deny</strong>” bit to <strong>4</strong>.</li></ul><h3>The Descriptor:</h3><p>So far, we’ve identified the token and the desired permissions (allow/deny). Now, we need to specify the group to which we want to assign these permissions. Each group in Azure DevOps has a unique identifier called a descriptor. Here’s an example:</p><pre>GET<br>https://dev.azure.com/{organization}/_apis/graph/groups?api-version=7.1-preview.1</pre><p>Replace <strong>dev.azure.com</strong> with your Azure DevOps domain name, <strong>{organization}</strong> with your organization name, and add the <strong>Authentication</strong> headers. This API call will return a list of all groups within your organization, including their descriptors and other information.</p><p>Sample Response:</p><pre>{<br>  &quot;count&quot;: 21,<br>  &quot;value&quot;: [<br>    {<br>      &quot;subjectKind&quot;: &quot;group&quot;,<br>      &quot;description&quot;: &quot;Members of this group have service-level permissions in this enterprise. For service accounts only.&quot;,<br>      &quot;domain&quot;: &quot;vstfs:///Framework/IdentityDomain/9b4f7336-c130-40bd-87f3-4201361ddbd1&quot;,<br>      &quot;principalName&quot;: &quot;[TEAM FOUNDATION]\\Enterprise Service Accounts&quot;,<br>      &quot;mailAddress&quot;: null,<br>      &quot;origin&quot;: &quot;vsts&quot;,<br>      &quot;originId&quot;: &quot;f0b87f93-fb29-4fd3-8f6a-0f8dfaf8600e&quot;,<br>      &quot;displayName&quot;: &quot;Enterprise Service Accounts&quot;,<br>      &quot;_links&quot;: {<br>        &quot;self&quot;: {<br>          &quot;href&quot;: &quot;https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Groups/vssgp.Uy0xLTktMTU1MTM3NDI0NS05MTM1MjY2ODMtODE4MDAzMjY0LTIyODA4NjYzMDUtOTA3OTI2NDgxLTAtMC0wLTAtMg&quot;<br>        },<br>        &quot;memberships&quot;: {<br>          &quot;href&quot;: &quot;https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Memberships/vssgp.Uy0xLTktMTU1MTM3NDI0NS05MTM1MjY2ODMtODE4MDAzMjY0LTIyODA4NjYzMDUtOTA3OTI2NDgxLTAtMC0wLTAtMg&quot;<br>        },<br>        &quot;membershipState&quot;: {<br>          &quot;href&quot;: &quot;https://vssps.dev.azure.com/Fabrikam/_apis/Graph/MembershipStates/vssgp.Uy0xLTktMTU1MTM3NDI0NS05MTM1MjY2ODMtODE4MDAzMjY0LTIyODA4NjYzMDUtOTA3OTI2NDgxLTAtMC0wLTAtMg&quot;<br>        },<br>        &quot;storageKey&quot;: {<br>          &quot;href&quot;: &quot;https://vssps.dev.azure.com/Fabrikam/_apis/Graph/StorageKeys/vssgp.Uy0xLTktMTU1MTM3NDI0NS05MTM1MjY2ODMtODE4MDAzMjY0LTIyODA4NjYzMDUtOTA3OTI2NDgxLTAtMC0wLTAtMg&quot;<br>        }<br>      },<br>      &quot;url&quot;: &quot;https://vssps.dev.azure.com/Fabrikam/_apis/Graph/Groups/vssgp.Uy0xLTktMTU1MTM3NDI0NS05MTM1MjY2ODMtODE4MDAzMjY0LTIyODA4NjYzMDUtOTA3OTI2NDgxLTAtMC0wLTAtMg&quot;,<br>      &quot;descriptor&quot;: &quot;vssgp.Uy0xLTktMTU1MTM3NDI0NS05MTM1MjY2ODMtODE4MDAzMjY0LTIyODA4NjYzMDUtOTA3OTI2NDgxLTAtMC0wLTAtMg&quot;<br>    },<br>    {...}<br>  ]<br>}</pre><p>Once you have the list of groups, you can identify the specific group you want. In this example, we will use the descriptor for the <strong>developers</strong> group.</p><h3>Granting Permissions with the API request:</h3><p>Now that we’ve identified all the necessary components, we can leverage the Azure DevOps API to grant the “<strong>Contribute</strong>” permission to a “<strong>Specific Repo</strong>” for the “<strong>developers</strong>” group. This involves sending a <strong>POST</strong> request to an Access Control Entries (ACEs) endpoint.</p><p><strong>Request:</strong></p><pre>POST<br>https://dev.azure.com/{organization}/_apis/accesscontrolentries/{security-namespace-id}?api-version=7.1-preview.1</pre><p>Replace <strong>dev.azure.com </strong>with your Azure DevOps domain name, <strong>{organization}</strong> and<strong> {security-namespace-id} </strong>which we retrieved earlier, and add the <strong>Authentication</strong> headers.</p><p><strong>Body:</strong></p><pre>{<br>  &quot;token&quot;: &quot;{token}&quot;,<br>  &quot;merge&quot;: false,<br>  &quot;accessControlEntries&quot;: [<br>    {<br>      &quot;descriptor&quot;: &quot;{descriptor}&quot;,<br>      &quot;allow&quot;: 4,<br>      &quot;deny&quot;: 0<br>    }<br>  ]<br>}</pre><p>Replace the required fields accordingly.</p><p>By sending this POST request to the “<strong>/accesscontrolentries</strong>” endpoint, you can grant the “<strong>Contribute</strong>” permission to the “<strong>developer</strong>” group for the specified Git Repo.</p><h3>Conclusion</h3><p>Azure DevOps APIs empower you to automate access control and streamline project management This approach empowers you to:</p><ul><li><strong>Enhance Efficiency:</strong> Automate repetitive permission management tasks, saving time and effort.</li><li><strong>Increase Scalability:</strong> Easily manage permissions for large teams and complex projects.</li><li><strong>Maintain Granularity:</strong> Define precise access control rules to your specific needs.</li></ul><p>While this blog explored the general concepts of using APIs for access control, do refer to the official Azure DevOps documentation for the latest and most secure practices.</p><p><strong>Reference Link </strong><a href="https://learn.microsoft.com/en-us/rest/api/azure/devops/security/access-control-entries/set-access-control-entries?view=azure-devops-rest-7.1&amp;tabs=HTTP#replace"><strong>— </strong>https://learn.microsoft.com/en-us/rest/api/azure/devops/security/access-control-entries/set-access-control-entries?view=azure-devops-rest-7.1&amp;tabs=HTTP#replace</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f0feb9e5c8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimizing Mongo Express for Multiple MongoDB Connections]]></title>
            <link>https://medium.com/@trivikramv/optimizing-mongo-express-for-multiple-mongodb-connections-e69889fc0be6?source=rss-1be6a927808f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e69889fc0be6</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[mongo-client]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[mongo-express]]></category>
            <dc:creator><![CDATA[Trivikram V]]></dc:creator>
            <pubDate>Tue, 23 Apr 2024 06:16:22 GMT</pubDate>
            <atom:updated>2024-04-23T06:35:52.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*snIRbw_udjASMkfSP0GTRA.png" /></figure><p>Mongo Express is a lightweight and flexible web-based MongoDB admin interface, perfect for developers who want to manage their MongoDB databases with ease in non-prod environments. In this blog, we’ll explore the complexities involved in configuring Mongo Express for multiple MongoDB connections, followed by discussing the solution and its impacts. We will be using Mongo-express as a Dockerized application.</p><p>For reference you can clone the mongo-express Github code base from <a href="https://github.com/mongo-express/mongo-express">here</a>.</p><h3>Challenge 1: Single MongoDB Server Connection Limitation</h3><p>As you may be aware, in the Mongo express client you can only specify one server connection using the environment variable `<strong><em>ME_CONFIG_MONGODB_SERVER / ME_CONFIG_MONGODB_URL`</em></strong>. And, furthermore, you can’t add any connections via the Mongo-express UI as well. This limitation presents a challenge when you have multiple MongoDB connections and need to set up just one Mongo Express application. Handling this scenario becomes difficult.</p><h3>Solution:</h3><p>To overcome this limitation, follow these steps:</p><ol><li><strong>Download the Configuration template: </strong>Download the template from <a href="https://github.com/mongo-express/mongo-express/blob/master/config.default.js">here</a>. This file serves as the base configuration for your Mongo Express application.</li><li><strong>Update the MongoDB Configuration: </strong>Inside the configuration file, find the section related to MongoDB configuration. This will be named `<strong><em>mongodb` </em></strong>or something similar. Basically it will contain the parameter responsible for defining the connection details (like `<strong><em>server`</em></strong> or `<strong><em>uri`</em></strong>)</li><li><strong>Add an Array of Connections: </strong>Replace the existing mongodb configuration with an array containing objects that define each MongoDB connection. Each object within the array should include properties like <strong>connectionString</strong>, <strong>admin</strong>, and <strong>connectionOptions</strong> (properties might vary depending on your configuration).</li></ol><p><strong>For example:</strong> If you want to add 2 mongo connections, add the following in the config file:</p><pre>export default {<br>  mongodb: [<br>  // Connection 1<br>  {<br>    mongo,<br>    getConnectionStringFromInlineParams,<br>    connectionName: &quot;conn_abc&quot;, // Enter desired name<br>    connectionString: &quot;mongodb://&lt;user&gt;:&lt;Password&gt;@&lt;mongo-sv1&gt;:27017/admin&quot;,<br>    connectionOptions: {<br>      // Provide additional connection options<br>      ssl: true,<br>    },<br>    admin: getBoolean(process.env.ME_CONFIG_MONGODB_ENABLE_ADMIN, false),<br>  },<br>  // Connection 2<br>  {<br>    mongo,<br>    getConnectionStringFromInlineParams,<br>    connectionName: &quot;conn_xyz&quot;, // Enter desired name<br>    connectionString: &quot;mongodb://&lt;user&gt;:&lt;Password&gt;@&lt;mongo-sv2&gt;:27017/admin&quot;,<br>    connectionOptions: {<br>      // Provide additional connection options<br>      ssl: true,<br>    },<br>    admin: getBoolean(process.env.ME_CONFIG_MONGODB_ENABLE_ADMIN, false),<br>  }<br>  ]</pre><p>After the changes you can dockerize the application and deploy it. Now you can see multiple connections as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EB-5MkfWd8RQTqIv" /><figcaption>mongo-express UI</figcaption></figure><h3>Challenge 2: Database Connectivity Issue with Read Credentials</h3><p>While we’ve successfully addressed the issue of MongoDB server connection limitations, we’re still encountering challenges when providing non-root credentials. This presents a significant security concern, particularly when the Mongo express application needs to only use admin credentials to fetch the Database list and its collections.</p><h3>Solution:</h3><p>Mongo Express retrieves the list of databases through the mongo client library using <strong>`connectionInfo.adminDb.listDatabases()`</strong>. However, this method fails when using read credentials.</p><p>To address this issue, replacing the line of code with <strong>`connectionInfo.client.db(‘admin’)`</strong> and then retrieving the list of databases resolves this problem.</p><p><strong>For example:</strong> Within the <strong>`lib/db.js`</strong> file, there exists an if-else condition upon the <strong>`admin`</strong> parameter from the <strong>`config.js`</strong> file to retrieve and incorporate the list of databases into the user interface. In the <strong>else</strong> clause, we can substitute the current code with the above approach. Refer the below code block:</p><pre>const adminDbs = connectionInfo.client.db(&#39;admin&#39;); // Access admin database<br>const allDbs = await adminDbs.command({ listDatabases: 1 }); // Fetch all DBs<br><br>for (let i = 0; i &lt; allDbs.databases.length; ++i) {<br>  const dbName = allDbs.databases[i].name;<br>  if (dbName) {<br>    if (connectionInfo.info.whitelist.length &gt; 0 &amp;&amp; !connectionInfo.info.whitelist.includes(dbName)) {<br>      continue;<br>    }<br><br>    if (connectionInfo.info.blacklist.length &gt; 0 &amp;&amp; connectionInfo.info.blacklist.includes(dbName)) {<br>      continue;<br>    }<br>    const connection = addConnection(connectionInfo.client.db(dbName), dbName);<br>    await connectionData.updateCollections(connection);<br>  }<br>}</pre><p>Once the modifications are complete, you can proceed to dockerize the application and deploy it. With these adjustments, you’ll observe multiple connections even when utilizing non-root credentials.</p><h3>Conclusion:</h3><p>In this blog, we explored the challenges and solutions for managing multiple MongoDB connections with Mongo Express. We identified two limitations:</p><ol><li><strong>Single Server Connection:</strong> Mongo Express traditionally allows connection to only one server.</li><li><strong>Read Credentials with Database List:</strong> Utilizing read credentials caused issues while retrieving the database list.</li></ol><p>We addressed these challenges by:</p><ol><li><strong>Modifying Configuration:</strong> Editing the config.js file to accept an array of connection details for each MongoDB host.</li><li><strong>Code Replacement:</strong> Replacing the code used to retrieve the database list with one that doesn’t rely on admin privileges.</li></ol><p>You can find the above mentioned changes in the code base along with the Dockerfile <a href="https://github.com/trivikram1999/mongo-express">here</a>.</p><p>These solutions enable developers to manage multiple MongoDB connections through a single Mongo Express instance while maintaining a level of security by using read credentials for most operations. However, it’s important to remember that Mongo Express is primarily designed for development and non-production environments. For robust management in production, consider dedicated database management tools.</p><p><em>That’s all for this article. Happy learning!</em></p><p>Authored by <a href="https://medium.com/u/1be6a927808f">Trivikram V</a> &amp; <a href="https://medium.com/u/640c5e36c7d8">Anitatyagi</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e69889fc0be6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>