<?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 Sachin Joshi on Medium]]></title>
        <description><![CDATA[Stories by Sachin Joshi on Medium]]></description>
        <link>https://medium.com/@satchinjoshi?source=rss-5581e9fa4d2c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DeQsc4xKC5fRK1LP.</url>
            <title>Stories by Sachin Joshi on Medium</title>
            <link>https://medium.com/@satchinjoshi?source=rss-5581e9fa4d2c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:11:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@satchinjoshi/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[IAM Role for Service Account (IRSA) with Elixir and ex_aws]]></title>
            <link>https://medium.com/@satchinjoshi/elixir-aws-auth-with-eks-service-account-e3fb62e3c595?source=rss-5581e9fa4d2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3fb62e3c595</guid>
            <category><![CDATA[iam-roles]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[elixir]]></category>
            <dc:creator><![CDATA[Sachin Joshi]]></dc:creator>
            <pubDate>Mon, 07 Nov 2022 21:21:35 GMT</pubDate>
            <atom:updated>2022-11-08T14:05:02.528Z</atom:updated>
            <content:encoded><![CDATA[<p>Managing credentials/secret is an essential part of security. It is a good practice to rotate the secret as frequently as possible based on the app and the business need. There are even tools that help to rotate the secret or even create a one-time secret. But if we could remove the secret and have other means to validate then it would help to remove one more thing to worry about. In this post, I will share how to setup the elixir app in Kubernetes (EKS) with IAM role.</p><p>AWS provides an official SDK for many popular languages, but if you work with Elixir, there is no official SDK. <a href="https://github.com/ex-aws/ex_aws">https://github.com/ex-aws/ex_aws</a> is the most popular unofficial package out there and does the job very well.</p><p>For apps running in EC2, you can attach an AWS role to the instance and get it working. However, for apps running in EKS it may not be wise to give the EKS node permission as any pods running can access the role (<em>Principle of Least Privilege). </em>So to solve this AWS has an integration that will connect the IAM role with the Kubernetes Service account.</p><p>Let&#39;s get to the code. First, let&#39;s add the elixir packages required and set the config. Make sure you have the following package installed.</p><pre>{:ex_aws, &quot;~&gt; 2.4&quot;},<br>{:ex_aws_sts, &quot;~&gt; 2.3&quot;},<br>{:sweet_xml, &quot;~&gt; 0.6&quot;},</pre><p>The ex_aws config should be defined as:</p><pre>config :ex_aws,<br>    secret_access_key: [{:awscli, &quot;profile_name&quot;, 30}],<br>    access_key_id: [{:awscli, &quot;profile_name&quot;, 30}],<br>    awscli_auth_adapter: ExAws.STS.AuthCache.AssumeRoleWebIdentityAdapter</pre><p>That is all you need to do in the elixir app. For setting up AWS roles and EKS you can just follow the AWS docs linked below</p><p><a href="https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html">https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html</a><br><a href="https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html">https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html</a><br><a href="https://docs.aws.amazon.com/eks/latest/userguide/pod-configuration.html">https://docs.aws.amazon.com/eks/latest/userguide/pod-configuration.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3fb62e3c595" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Auth0 manual id_token validation with Node.js]]></title>
            <link>https://medium.com/@satchinjoshi/auth0-manual-id-token-validation-with-node-js-49a533d28690?source=rss-5581e9fa4d2c------2</link>
            <guid isPermaLink="false">https://medium.com/p/49a533d28690</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[idtoken]]></category>
            <category><![CDATA[auth0]]></category>
            <category><![CDATA[jwt-authentication]]></category>
            <dc:creator><![CDATA[Sachin Joshi]]></dc:creator>
            <pubDate>Sat, 19 Feb 2022 16:09:08 GMT</pubDate>
            <atom:updated>2022-02-19T16:09:08.640Z</atom:updated>
            <content:encoded><![CDATA[<p>You may have a use case where you might want to validate the id_token of auth0 manually. I had a situation where Auth0 was used partially and had to be integrated into the existing auth system.</p><p>If you do a quick search about how to validate the id_token received from auth0 callback then you will probably not find it. There are npm packages that you can use express as a middleware that will do the validation. And that is the most common way one will use it. Check the link below</p><pre><a href="https://github.com/auth0/node-jwks-rsa/tree/61b5740b3846f74fa6d631be6712405700d9c163/examples/express-demo">https://github.com/auth0/node-jwks-rsa/tree/61b5740b3846f74fa6d631be6712405700d9c163/examples/express-demo</a></pre><p>But we want to check it manually. So to start, install 2 npm packages.</p><pre>npm install jwks-rsa jsonwebtoken</pre><p>Check the code below.</p><pre>const jwksClient = require(&#39;jwks-rsa&#39;);<br>const jwt <strong>=</strong> require(&#39;jsonwebtoken&#39;);</pre><pre>const config = {<br>  auth0: {<br>    domain: &lt;replace-me&gt;,<br>    client_id: &lt;replace-me&gt;,<br>  },<br>};</pre><pre>async function decodeAndVerifyToken(token) {<br>  const client = jwksClient({<br>    jwksUri: `<a href="https://${config.auth0.domain}/.well-known/jwks.json%60">https://${config.auth0.domain}/.well-known/jwks.json`</a>,<br>  });</pre><pre>  const kid = getKid(token);<br>  const key = await getSigningKey(client, kid);<br>  const signingKey = key.getPublicKey();</pre><pre>  return jwt.verify(token, signingKey, {<br>    audience: config.auth0.client_id,<br>    issuer: `<a href="https://${config.auth0.domain}/%60">https://${config.auth0.domain}/`</a>,<br>  });<br>}</pre><pre>function getKid(token) {<br>  const decodedToken = jwt.decode(token, { complete: true });<br>  if (!decodedToken) {<br>    throw new Error(&#39;Invalid token&#39;);<br>  }</pre><pre>  return decodedToken.header.kid;<br>}</pre><pre>function getSigningKey(client, kid) {<br>  return new Promise((resolve, reject) =&gt; {<br>    client.getSigningKey(kid, (err, res) =&gt; {<br>      if (err) {<br>        reject(err);<br>      }<br>      resolve(res);<br>    });<br>  });<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49a533d28690" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>