<?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 Shaarif Khan on Medium]]></title>
        <description><![CDATA[Stories by Shaarif Khan on Medium]]></description>
        <link>https://medium.com/@shaarifkhan999?source=rss-c0962da9dfb0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*e2P11J5BAww44Wue</url>
            <title>Stories by Shaarif Khan on Medium</title>
            <link>https://medium.com/@shaarifkhan999?source=rss-c0962da9dfb0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 28 May 2026 00:57:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shaarifkhan999/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[Unlocking Federated Identity: How AWS IRSA Works Inside EKS]]></title>
            <link>https://medium.com/@shaarifkhan999/unlocking-federated-identity-how-aws-irsa-works-inside-eks-aa7a6035943d?source=rss-c0962da9dfb0------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa7a6035943d</guid>
            <category><![CDATA[federated-identity]]></category>
            <category><![CDATA[sts-token]]></category>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[irsa]]></category>
            <dc:creator><![CDATA[Shaarif Khan]]></dc:creator>
            <pubDate>Mon, 29 Sep 2025 16:07:43 GMT</pubDate>
            <atom:updated>2025-09-29T16:07:43.279Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*ayUORcrzqHSuvH4weNIFDA.png" /></figure><p>Following my earlier article on <a href="https://medium.com/@shaarifkhan999/demystifying-federated-identity-management-fim-and-its-clever-use-in-eks-162a4dd7763f"><strong><em>Demystifying Federated Identity Management (FIM) and Its Clever Use in EKS</em></strong></a>, this piece dives deeper into how AWS IRSA leverage FIM inside EKS.</p><blockquote><strong>EKS and about IRSA</strong>: <em>EKS is a managed Kubernetes service offered by Amazon Web Services (AWS) that simplifies the deployment, management, and scaling of containerised applications using Kubernetes. Whereas IRSA is a feature in EKS that allows kubernetes pods to securely assume IAM role to access AWS resources</em>.</blockquote><p>Imagine a scenario where you are running an application inside a pod, and that application needs to access an S3 bucket to list some resources. Providing long-term/permanent credentials to application to access AWS resources wouldn’t be prudent approach. Short term credentials, with limited access to particular s3 bucket — no easy way to achieve that.</p><p>What if we can assume a role( having restrained permission) directly from a pod? <strong>BUT</strong> dont overlook the fact that we can’t assume a role unless we are already authenticated with AWS.</p><p><strong>IRSA</strong> comes to solve exactly that, which functions on top of <strong>Federated identity management</strong> — in a very cunning way. Let me walk us through each step of how the pod initiates and authenticated requests to assume an IAM role.</p><p>But before we get into too much details, let me give you a refresher of how does identity and authentication works in kubernetes.</p><h4><strong>Background: Kubernetes Service Accounts</strong></h4><p>Kubernetes has this concept of Service Account, which is a kind of non-human entity, that provides a distinct identity in a kubernetes cluster. Pods, system components and other entities can get access to kubernetes’s api by getting access to Service Account Credentials (service account token).</p><p>With Service Account, pod gets an identity which is limited to kubernetes cluster. Kubernetes OIDC server generates a JWT token for service account, which then gets mounted inside a pod at /var/run/secrets/kubernetes.io/serviceaccount/ .<br>Pod uses this token to authenticate while calling the <em>kube-api-server</em>.</p><p>Now that we understand how Service Accounts work in Kubernetes, let’s see how IRSA extends this mechanism into AWS IAM.</p><h4>Enter <strong>IRSA (IAM Roles for Service Accounts):</strong></h4><p>IRSA extend this concept by using some magic of Identity Federation to let the pod use the same service_account token to assume <em>AWS IAM</em> role and access AWS resources. Using IRSA in EKS is quite simple, annotate the Service Account with the <em>IAM role ARN</em>, the service account wants to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fnmK7PLqmmm19wevpuG4QA.png" /><figcaption>illustration of service account annotation with IAM role and IAM trust policy</figcaption></figure><p>after this step, the pods get the service account token, mounted at</p><p>/var/run/secrets/eks.amazonaws.com/serviceaccount/</p><p>Lets assume that we are deploying our application in kubernetes called “<strong><em>best-app</em>”</strong>. if we navigate to the /var/run/secrets/eks.amazonaws.com/serviceaccount path inside a <strong><em>best-app</em></strong> pod, we would find a token file, containing a <strong>JWT</strong> token — when decoded, looks similar to this</p><pre>{<br>  &quot;aud&quot;: [<br>    &quot;sts.amazonaws.com&quot;<br>  ],<br>  &quot;exp&quot;: 1234567890,<br>  &quot;iat&quot;: 1234567890,<br>  &quot;iss&quot;: &quot;https://oidc.eks.us-west-2.amazonaws.com/id/EXAMPLED539D4633E53DE1B716D3041E&quot;,<br>  &quot;jti&quot;: &quot;best-app_jti_uuid&quot;,<br>  &quot;kubernetes.io&quot;: {<br>    &quot;namespace&quot;: &quot;dummy-namespace&quot;,<br>    &quot;node&quot;: {<br>      &quot;name&quot;: &quot;dummy-node-name.compute.internal&quot;,<br>      &quot;uid&quot;: &quot;dummy_node_uid&quot;<br>    },<br>    &quot;pod&quot;: {<br>      &quot;name&quot;: &quot;best-app&quot;,<br>      &quot;uid&quot;: &quot;best-app_uid&quot;<br>    },<br>    &quot;serviceaccount&quot;: {<br>      &quot;name&quot;: &quot;best-app-service-account&quot;,<br>      &quot;uid&quot;: &quot;best-app_service_account_uid&quot;<br>    }<br>  },<br>  &quot;nbf&quot;: 1234567890,<br>  &quot;sub&quot;: &quot;system:serviceaccount:dummy-namespace:best-app-service-account&quot;<br>}</pre><p>this is an <strong>OIDC JWT token </strong>issued by EKS OIDC server to the service account associated with <em>best-app</em> pod.</p><p>the <strong><em>best-app</em></strong> pod uses that token while calling the <a href="https://sts.amazonaws.com/">https://sts.amazonaws.com</a> to assume a role with permission to access S3 bucket. Who issued that token? and how AWS STS trust this token.</p><p>Lets walkthrough each step of how the trust establishes.<br>the best-app pod uses that token while calling the <a href="https://sts.amazonaws.com/">https://sts.amazonaws.com</a> to assume a role with permission to access S3 bucket. Who issued that token? and how AWS STS trust this token.</p><h4>Step: 1: EKS OIDC Provider Setup</h4><p>when you create an eks cluster, AWS automatically <strong>provisions an OIDC issuer endpoint</strong> for your cluster. looks similiar to</p><pre>https://oidc.eks.us-west-2.amazonaws.com/id/EXAMPLED539D4633E53DE1B716D3041E</pre><p>This OIDC endpoint is hosted by your eks (which is essentially your cluster Idp) — exposes some metadata at <strong>/.well-known/openid-configuration</strong> we will see later down the road why it is needed.</p><h4>Step: 2: Establish trust in AWS IAM</h4><p><strong>2.1: Registering EKS OIDC Server in IAM<br></strong>in this scenario, AWS STS is an <strong><em>SP(service provider)</em></strong> which need to trust the external <strong><em>Idp provider</em></strong>, we create this trust in AWS IAM by registering EKS OIDC Server as trusted Identity Provider in IAM.</p><pre>aws iam create-open-id-connect-provider \\<br>--url &lt;https://oidc.eks.us-west-2.amazonaws.com/id/EXAMPLED539D4633E53DE1B716D3041E&gt; \\<br>--client-id-list [sts.amazonaws.com](&lt;http://sts.amazonaws.com/&gt;) \\<br>--thumbprint-list &lt;thumbprint&gt;</pre><p>it will allow STS to trust any JWT token signed by the CA having the provided thumbprint, where the issuer is</p><pre>https://oidc.eks.us-west-2.amazonaws.com/id/EXAMPLED539D4633E53DE1B716D3041E](&lt;https://oidc.eks.us-west-2.amazonaws.com/id/EXAMPLED539D4633E53DE1B716D3041E&gt;)  and the client/aud will be sts.amaznaws.com</pre><p>and the <strong>client/aud</strong> will be <strong>sts.amaznaws.com</strong></p><p><strong>2.2- Creating a Trust Policy in IAM role</strong></p><p>You define a trust policy that restricts which Kubernetes Service Accounts can assume the role. Example:</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Federated&quot;: &quot;arn:aws:iam::&lt;account-id&gt;:oidc-provider/oidc.eks.us-west-2.amazonaws.com/id/EXAMPLE...&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRoleWithWebIdentity&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;oidc.eks.us-west-2.amazonaws.com/id/EXAMPLE...:sub&quot;: &quot;system:serviceaccount:my-namespace:best-app-serviceaccount&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><h4>Step 3: Pod Uses Projected ServiceAccount Token</h4><p>pod uses the token projected at</p><pre>/var/run/secrets/eks.amazonaws.com/serviceaccount/token</pre><h4>Step 4: Pod Makes STS AssumeRoleWithWebIdentity Call</h4><p>pod using the AWS SDK initiates the request to STS, which looks something like this</p><pre>aws sts assume-role-with-web-identity \<br> — role-arn arn:aws:iam::123456789012:role/BestAppRole \<br> — role-session-name best-app-session \<br> — web-identity-token file:///var/run/secrets/eks.amazonaws.com/serviceaccount/token \<br> — duration-seconds 3600</pre><h4>Step 5: STS Validates the OIDC Token</h4><p>STS validates that the OIDC token is issued by the trusted IDP(step 2) and checks the integrity of the token by verifying its signature using a public key exposed at &lt;OIDC_URL/keys&gt;</p><pre>https://oidc.eks.ap-southeast-1.amazonaws.com/id/3C093DFA14C1920DF318FFCC16EB8450/keys</pre><h4>Step 6: STS returns the temporary Credentials</h4><p>STS return a response, which looks similiar to</p><pre>{<br> “Credentials”: {<br> “AccessKeyId”: “ASIA….”,<br> “SecretAccessKey”: “wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY”,<br> “SessionToken”: “IQoJb3JpZ2luX2VjE…”,<br> “Expiration”: “2025–09–25T20:45:07Z”<br> },<br> “AssumedRoleUser”: {<br> “AssumedRoleId”: “ARO123EXAMPLE:best-app-session”,<br> “Arn”: “arn:aws:sts::123456789012:assumed-role/BestAppRole/best-app-session”<br> }<br>}</pre><p>The entire flow looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xkrz_337xKIorTQAVx3CZA.png" /><figcaption>illustration of end-to-end communication b/w EKS, Pod and AWS Services</figcaption></figure><p>this illustration summarizes the entire end-to-end flow we discussed in this article. it may seem overwhelming at first, but as you start to get a grasp of the concept. It will start to make sense and becomes a reference point for you in future.</p><p>IRSA is widely adopted today and enables the team to architect a robust solution while designing system on EKS and AWS. It enables the kubernetes entities to leverage the fine-grained access control provided by AWS IAM role, streamlining secure access to AWS resources.</p><p>In this article, we introduced IRSA, explained its foundations in Federated Identity Management, and traced the request flow between EKS and AWS.</p><p>Now that you have learned about the inner workings, I am leaving a question for you.<strong><em> How would you replicate IRSA in a self-hosted Kubernetes cluster running on AWS? Can you enable to pods inside your self-hosted kubernetes cluster to assume IAM role?</em></strong></p><p>Let me know what solution you come up with, I hope it helped you get a good grasp of FIM and related concepts. Feel free to gift your feedbacks and suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa7a6035943d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Federated Identity Management (FIM) and Its Clever Use in EKS]]></title>
            <link>https://medium.com/@shaarifkhan999/demystifying-federated-identity-management-fim-and-its-clever-use-in-eks-162a4dd7763f?source=rss-c0962da9dfb0------2</link>
            <guid isPermaLink="false">https://medium.com/p/162a4dd7763f</guid>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[oidc]]></category>
            <dc:creator><![CDATA[Shaarif Khan]]></dc:creator>
            <pubDate>Sat, 06 Sep 2025 19:20:57 GMT</pubDate>
            <atom:updated>2025-09-06T19:45:38.057Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jnLP6Ix8-gezRyh9Ws48A.png" /></figure><p>Chances are you’ve already encountered Single Sign-On (SSO), OAuth, OIDC, or JWT in your work.</p><p>These days, the ecosystem of tutorials and playbooks has become so rampant that one often only needs to follow a quick 5–7 step guide to achieve a task. The rise of LLM-based chat agents has further exacerbated this trend. Whether or not this is a bad thing is debatable, but one thing is certain: engineers are now less focused on truly understanding the technology and more focused on simply moving the ticket from ‘in-progress’ to ‘done.’.</p><p>While having the superpower of search engine and now intelligent chat engines help quickly move the tickets but they also make us susceptible to overlooking the remarkable technology and architectural thinking behind the tools we use</p><p>In this article, I will walk you through the simple yet brilliant concepts behind federated identity management. By the end, you should be able to clearly distinguish its features and find your way out of the quagmire of vague explanations around <strong>SSO</strong> and <strong>FIM</strong></p><blockquote>A textbook definition of FIM is<br> “<strong>Federated Identity Management (FIM) allows users to access multiple systems and applications across different organizations or domains using a single set of credentials</strong>”</blockquote><p>At first, this definition may sound confusing, but once you get the hang of it, it starts to make sense.</p><p>Lets start with SSO</p><h3>What is Single Sign-On (SSO)</h3><p>Chances are, you’ve encountered SSO when logging into your organisation’s internal apps via a central portal. SSO is a paradigm that lets you seamlessly access multiple applications under a “SINGLE” organisation without needing to re-authenticate or maintain separate credentials for each one. It leverages protocols like OIDC and SAML to enable frictionless authentication.</p><h3>What is Federated Identity Management (FIM)?</h3><p>What exactly does FIM do? Explaining identity federation in simple terms isn’t easy, so first I’ll introduce two basic terms we’ll use throughout this article</p><p><strong><em>Identity Provider (IdP)</em></strong><em> </em>— An IdP is an entity/service that creates and manages user identities and authenticates users to other applications that rely on it. For example, Okta, Authelia, or Google can act as an IdP</p><p><strong><em>Service Provider/ Relying Party</em></strong> : A service provider (<em>SP/RP</em>) is an entity that provides services to a user. it could be a SaaS application, a web service provider or a partner organisation. <em>For example, Medium website (when it prompts the user to login via any social website)</em>.</p><p>Federated Identity Management uses many of the same protocols, but it introduces a paradigm that enables authentication across organisations. In essence, FIM establishes trust (<strong>a <em>federation</em></strong>) between an <strong><em>IdP</em></strong> and an <strong><em>SP</em></strong>, so a user can authenticate once and then access resources across both domains without logging in again.</p><p>When two domains are federated, a user can authenticate to one domain and then access resources in the other domain without having to perform a separate login process.</p><p><strong>Lets Understand it With the help of a Scenario:</strong></p><p>Imagine an employee at <strong><em>Company A</em></strong> who logs in once each morning through the <strong><em>Company B’s</em></strong> SSO provider (say Keycloak, Authelia, etc.) to access all internal portals and applications. Now image a <strong><em>Company A</em></strong> has recently onboarded a SaaS application from <strong><em>Company B</em></strong> for its employees. While the SaaS offers its own signup mechanism, but, it would be extremly inconvenient for, say, 1000 users to create an account for that tool.</p><p>So? Could there be a way that <em>Company A’s</em> employees login once with <em>Company B’s</em> IdP and “automagically” get access to the SaaS tool?</p><p>Federated identity management exactly solves that by establishing trust between Organisation A and Organisation B.</p><p>In this case, <em>Company A</em> acts as an Identity provider (<em>IdP</em>) and the <em>Company B’s</em> SaaS act as (<em>SP/RP</em>) service provider. As part of the their trust agreement, <em>Company A’s</em> IdP registers the Company B’s application as a trusted client. This way, when a user needs access to SaaS, the SP can redirect the user to Company A’s Idp portal for authentication. The SP then uses the IdP’s published JWKS (JSON Web Key Set) to verify the authenticity of the token issued by IdP.</p><p>As Part of the Standard, the IdP also exposes a “discovery document” (usually at an endpoint like <strong>https://idp.example.com/.well-known/openid-configuration</strong> This is the JSON document containing the IdP’s public configuration, such as URL of the authorisation server, token endpoints and the location of its JWKS keys.</p><p>this is a sample json document returned by this endpoint contains</p><pre>{<br>&quot;issuer&quot;: &quot;https://login.companyA.com&quot;,<br>&quot;authorization_endpoint&quot;: &quot;https://login.companyA.com/oauth2/authorize&quot;,<br>&quot;token_endpoint&quot;: &quot;https://login.companyA.com/oauth2/token&quot;,<br>&quot;jwks_uri&quot;: &quot;https://login.companyA.com/.well-known/jwks.json&quot;,<br>...<br>}</pre><ul><li>The SP fetches this JWKS URL and caches the keys.</li></ul><p>This process proves to the RP:</p><blockquote><em>Any </em><strong>id_token</strong><em> signed with one of these keys truly came from </em>Company A’s<em> IdP.</em></blockquote><p>The entire end to end flow looks like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i3ctTFwr-SOJJzRU6f0XUQ.png" /><figcaption>High-level flow of federated authentication between Company A’s IdP and Company B’s SP.</figcaption></figure><p>Federated Identity Management is widely adopted today, and chances are you’re already using it without realising it. One clever implementation is in AWS EKS with <strong>IRSA</strong> (IAM Roles for Service Accounts).</p><p>In this writeup, we learned about the subtle difference b/w SSO and FIM and briefly peeked into the working of how the underlying protocol actually works. Now, the next time, you click on “<strong><em>Signin with Google</em></strong>” button on a website, you’ll know what is happening behind the scenes.</p><p>I hope it helped you get a good hang of the concept. In the next article, we will discuss the intricacies and specifics about EKS’s use of FIM — specifically how the trust establishes b/w the two entities such that a pod gets access to the allowed AWS resources. Until then stay tuned and feel free to share your feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=162a4dd7763f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>