<?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 Jagadeesh Dachepalli on Medium]]></title>
        <description><![CDATA[Stories by Jagadeesh Dachepalli on Medium]]></description>
        <link>https://medium.com/@jagadeesh-dachepalli?source=rss-ddc63b02152f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4QLQNTL2THZg_7EXW5l8ew.png</url>
            <title>Stories by Jagadeesh Dachepalli on Medium</title>
            <link>https://medium.com/@jagadeesh-dachepalli?source=rss-ddc63b02152f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 22:43:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jagadeesh-dachepalli/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[Add Secondary protection to your web apps authentication — TOTP (2FA-two factor authentication)]]></title>
            <link>https://jagadeesh-dachepalli.medium.com/add-secondary-protection-to-your-web-apps-authentication-totp-2fa-two-factor-authentication-632426172285?source=rss-ddc63b02152f------2</link>
            <guid isPermaLink="false">https://medium.com/p/632426172285</guid>
            <category><![CDATA[2fa-authentication]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[otp-verification]]></category>
            <category><![CDATA[totp]]></category>
            <category><![CDATA[mfa]]></category>
            <dc:creator><![CDATA[Jagadeesh Dachepalli]]></dc:creator>
            <pubDate>Sat, 12 Nov 2022 17:28:46 GMT</pubDate>
            <atom:updated>2022-11-12T17:50:57.338Z</atom:updated>
            <content:encoded><![CDATA[<h3>Add Secondary lock to your web apps authentication — <strong>TOTP </strong>(<strong>2FA</strong>-two factor authentication)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7Rvf3lq36ZR5rANnX5iRw.png" /></figure><p>2FA aka Two Factor Authentication is the most commonly used additional layer authentication mechanism in popular applications for the past few years, out of multiple 2FA approaches available only 2 got very popular — Push Notification and Software Tokens. In this blog, I will explain how we can use the Software Tokens approach for 2FA.</p><p>Software Tokens aka <a href="https://en.wikipedia.org/wiki/Time-based_one-time_password">TOTP(Time-based One-time Password)</a>, can be used with the help of App-based authenticators which help in generating a valid one-time password. I’ve used Python’s <a href="https://github.com/pyauth/pyotp">pyotp library</a> to generate and verify one-time passwords.</p><pre># code for generating the TOTP<br>data = request.form<br>email = data[&#39;email&#39;]<br>password = data[&#39;psw&#39;]<br>create_user(email, password)<br>secret_string = pyotp.random_base32()<br>totp = pyotp.TOTP(secret_string)<br>create_secret(email, secret_string)<br>totp_uri = totp.provisioning_uri(name=email, issuer_name=&quot;Jagadeesh TOTP Demo&quot;)<br>return render_template(&#39;token.html&#39;, totp_uri=&quot;https://chart.googleapis.com/chart?cht=qr&amp;chs=500x500&amp;chl=&quot; + totp_uri<br></pre><pre># Code for validating the TOTP<br>data = request.form<br>email = data[&#39;email&#39;]<br>otp = data[&#39;otp&#39;]<br>user = get_secret(email)<br>totp = pyotp.TOTP(user[0][1])<br>if totp.now() != otp:<br>    return render_template(&#39;login_fail.html&#39;)<br>return render_template(&#39;login_success.html&#39;)</pre><p><strong>For this demo</strong>, I’ve used a sample <a href="https://flask.palletsprojects.com/en/2.2.x/">Flask app</a> with <a href="https://jinja.palletsprojects.com/en/3.1.x/integration/#flask">Jina templates</a> (for UI) to navigate through the <strong>Registration</strong> and the <strong>Login</strong> features with the help of TOTP based MFA mechanism. <a href="https://github.com/jagadish432/totp"><strong><em>Here’s the link to the project’s GitHub repository</em></strong></a><strong><em>. </em></strong>As it’s a sample demo app, I’ve used <a href="https://docs.python.org/3/library/sqlite3.html">Python’s SQLite3</a> for the built-in database feature to reduce the overhead of using an actual database for sample/development scope.</p><p>While registering the user account itself the web app can generate the TOTP secret key in form of a QRcode and Customers/Users can scan the QRcode with the help of App-based authenticators such as Google Authenticator, Microsoft Authenticator, Twilio Authy, etc., and during the login process, web apps should be designed to ask OTP <em>as an additional layer</em> after the <em>basic user ID and password check</em>, and users can provide the same from the Authenticator app by which they scanned in the registration step.</p><p><strong>Step-1: </strong>Start the Application, open localhost with 5000 port(Flask default port), provide the user email, and give a new password, click on “Register”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JK_0XKFccDhu9nxKonXHmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_rG9piw4_sm0Vakl4uN5A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eMoVEDtKkKQcgnnAaJcUNg.png" /></figure><p><strong>Step-2: </strong>A QRcode appears for users to scan, which is used for login later on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fh6ugujeuqXa5eTxdpgHNg.png" /></figure><p><strong>Step-3: </strong>Test by providing the wrong OTP.</p><p>the below particular line helps us in validating the DB stored secret key’s TOTP <strong>vs</strong> User provided TOTP</p><pre>otp = data[&#39;otp&#39;] # User provided TOTP<br>user = get_secret(email) # Fetching DB stored user secret row<br>totp = pyotp.TOTP(user[0][1]) # DB stored User Secret value<br>if totp.now() != otp: # validating both values</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60HMITTm94TqE86oNOW2VA.png" /></figure><p>As we entered the wrong OTP, the flask app redirects us to the error page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_vAjXEnSaGA825dpsy6GVQ.png" /></figure><p><strong>Step-4: </strong>Provide the correct OTP from the Authenticator app(Google Authenticator in this case)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*wwxOqOtz3cXL6SmCAd2i9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWt7K73bAlEBVeM3qIP3zg.png" /></figure><p>As we enter the correct OTP, the Flask app navigates to the success page.(in a real scenario it could be the application’s main page eg: Facebook’s timeline page, AWS Console homepage, etc..)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S0Ml4MbK9dcQZtFm3WgWeg.png" /></figure><p><strong>Conclusion</strong></p><p>TOTP has also some disadvantages, As we all know — no approach is perfect for anyone. So, I suggest we must go through the pros and cons of any approach before we pick it up.</p><p>Also, please let me and others know in the <em>comments section</em> if you come across any similar/better mechanisms for authentication in recent times. Thanks for taking the time to read this through.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=632426172285" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reduce the cost of your unused AWS DynamoDB tables by turning them to “on-demand” mode]]></title>
            <link>https://jagadeesh-dachepalli.medium.com/reduce-the-cost-of-your-unused-aws-dynamodb-tables-by-turning-them-to-on-demand-mode-6bdc044c8803?source=rss-ddc63b02152f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bdc044c8803</guid>
            <category><![CDATA[serverless-framework]]></category>
            <category><![CDATA[aws-sns]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[aws-cost-optimization]]></category>
            <dc:creator><![CDATA[Jagadeesh Dachepalli]]></dc:creator>
            <pubDate>Sun, 28 Mar 2021 07:09:29 GMT</pubDate>
            <atom:updated>2021-03-28T07:49:24.429Z</atom:updated>
            <content:encoded><![CDATA[<h3>I am a Senior Software Engineer, having around 5 years of IT experience, predominantly worked with AWS, Python, DynamoDB.</h3><p>This post/story has been inspired by an AWS blog that I recently came across when I was reading the dynamodb blogs, which is written by <strong>Jongnam Lee</strong> and <strong>Masudur Rahaman Sayem. </strong>AWS blog link -<a href="https://aws.amazon.com/blogs/database/safely-reduce-the-cost-of-your-unused-amazon-dynamodb-tables-using-on-demand-mode/">https://aws.amazon.com/blogs/database/safely-reduce-the-cost-of-your-unused-amazon-dynamodb-tables-using-on-demand-mode/</a></p><p>The above-mentioned blog is to safely reduce the cost of the DynamoDB tables in case they have been not used but might be used by some applications in the future. So, we cannot delete them unless we get approvals from the respective application’s owners. So, instead, we will change their I/O mode to “On-Demand” mode so that we will not incur any cost for unused tables. I highly recommend reading the above AWS blog prior to this blog.</p><p>I have followed the same approach as they’ve mentioned(<strong>nodejs </strong>solution)in the AWS blog, but just implemented a <strong>Python solution</strong> for it. I also added few other features namely — the <a href="https://www.serverless.com/framework/docs/"><strong>serverless framework</strong></a> for easy deployments of the lambda, cron jobs, and <a href="https://aws.amazon.com/sns/?whats-new-cards.sort-by=item.additionalFields.postDateTime&amp;whats-new-cards.sort-order=desc"><strong>SNS </strong></a>usage to send the statistics of updated DynamoDB tables to subscribers subscribed to the SNS Topic (Email address in my case)</p><p>In the code, we define a DynamoDB table as unused if the table hasn’t had any read or write activity in the last <em>days_to_search_from</em> days, here <em>days_to_search_from </em>is an environment variable we set up using the serverless framework. (please find the Github repo link below to explore the code at your convenience)</p><p>Here are some snippets of my code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KPWlzGfdrABFDZu0vf1EPw.png" /><figcaption>function to get a single dynamodb table’s info</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9INYjj7MfdcE0ns6RD4yKw.png" /><figcaption>function to get dynamodb table’s metrics statistics</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VUOHQBcB7dnd7m0632gm9Q.png" /><figcaption>function to update DynamoDB table I/O mode to On-Demand</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*IRqhRfGWvQBz766QR_Gq_Q.png" /><figcaption>lambda handler — Starting function for AWS Lambda</figcaption></figure><p>Screenshots of my DynamoDB tables - before and after our lambda runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ZGF0jcHGztV-kIkDkSzAw.png" /><figcaption>snapshot of dynamodb tables before the lambda execution</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HYehq4eXhh8PJAuDoWBegg.png" /><figcaption>snapshot of the dynamodb tables after the lambda function execution</figcaption></figure><p>From the above snapshots of dynamodb tables, you can clearly see that two tables (test1, test2) have been changed to use ‘On-Demand’ I/O mode as they found out to be the only tables that are <strong>inactive </strong>based on our ‘project configuration/settings’</p><p>Here’s the link to my GitHub repo: <a href="https://github.com/jagadish432/reduce-inactive-dynamodb-table">https://github.com/jagadish432/reduce-inactive-dynamodb-table</a></p><p>I have used the <strong>Serverless framework</strong> here because it’s easy to manage deployments and also easy to manage configurable data (like the number of days since when we wanted to check, AWS region, multiple deployments regions/environments (like dev, staging, prod), email_address value for the SNS subscribed endpoint, etc. However, we are free to choose other frameworks like <a href="https://aws.amazon.com/amplify/"><strong>Amplify</strong></a><strong>, </strong><a href="https://pypi.org/project/zappa/"><strong>Zappa</strong></a><strong>, </strong>etc, but still mostly depends on whether we are starting a new isolated project or we want to add this to an existing python project.</p><p>The current code deploys an AWS lambda function and applies the CRON rule on it to run on the first day of every month. However, we can modify this schedule rate. Also, the lambda doesn’t run immediately after the stack creation/update, so if we need the lambda to run immediately after the stack creation or stack update i.e, after deploying new changes, I believe we can use SNS here again to call our lambda function on the message publish, and even before that, we need to capture the stack creation/update event and then trigger message to the SNS topic. Please refer to this <a href="https://stackoverflow.com/questions/41350483/is-it-possible-to-trigger-a-lambda-on-creation-from-cloudformation-template"><strong>StackOverflow </strong></a>link to get some idea.</p><p>This is the sample email message we will get from SNS in case there are any inactive dynamodb tables found and updated to On-Demand mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uQuVQBregRIMWlwEtVlacQ.png" /><figcaption>email received from SNS when the lambda found inactive tables and updated them to On-Demand mode</figcaption></figure><p>This is my first ever post/article, please suggest me in case of any changes required on this post in the comments section, so that I will improve my writings further.</p><p>Thank you for reading this, I hope this helped you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bdc044c8803" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>