<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sonali kumari shahi</title>
    <description>The latest articles on DEV Community by sonali kumari shahi (@sonalishahi).</description>
    <link>https://dev.to/sonalishahi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3961186%2Fa77656d0-9e2b-4c61-afb2-e661de219a9e.png</url>
      <title>DEV Community: sonali kumari shahi</title>
      <link>https://dev.to/sonalishahi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sonalishahi"/>
    <language>en</language>
    <item>
      <title>Authentication vs Authorization: Understanding the Difference in Spring Security</title>
      <dc:creator>sonali kumari shahi</dc:creator>
      <pubDate>Wed, 03 Jun 2026 11:36:03 +0000</pubDate>
      <link>https://dev.to/sonalishahi/authentication-vs-authorization-understanding-the-difference-in-spring-security-4j4c</link>
      <guid>https://dev.to/sonalishahi/authentication-vs-authorization-understanding-the-difference-in-spring-security-4j4c</guid>
      <description>&lt;p&gt;When I started learning Spring Security, I kept seeing two terms everywhere:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authentication and Authorization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At first, they sounded almost the same to me.&lt;br&gt;
But as I learned more, I realized they answer two completely different questions.&lt;br&gt;
Understanding this difference is important because these concepts are at the heart of every secure application.&lt;br&gt;
Let's break them down in the simplest way possible.&lt;/p&gt;
&lt;h2&gt;
  
  
  Authentication: Who Are You?
&lt;/h2&gt;

&lt;p&gt;Authentication is the process of verifying a user's identity.&lt;br&gt;
In simple words, the application asks: &lt;strong&gt;"Who are you?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, when you log in using your username and password:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   Username: sonali
   Password: ********
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The application checks whether these credentials are correct.&lt;/strong&gt;&lt;br&gt;
If they are correct, you are authenticated.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Think of it like entering a college campus.&lt;br&gt;
The security guard checks your ID card to confirm that you are actually a student.&lt;br&gt;
That's authentication.&lt;br&gt;
✅ Identity Verified&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Authorization: What Are You Allowed To Do?
&lt;/h2&gt;

&lt;p&gt;After authentication, another question is asked: &lt;strong&gt;"What are you allowed to do?"&lt;/strong&gt;&lt;br&gt;
This is authorization.&lt;br&gt;
&lt;strong&gt;Even if two users are logged in, they may not have the same permissions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Admin can manage users&lt;/li&gt;
&lt;li&gt;Employee can view data&lt;/li&gt;
&lt;li&gt;Customer can access only their own account&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Authorization decides what resources a user can access.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Using the same college example:&lt;br&gt;
The security guard verified your identity at the gate.&lt;br&gt;
But that doesn't mean you can enter every room on campus.&lt;br&gt;
Some rooms may be restricted to staff members only.&lt;br&gt;
That's authorization.&lt;br&gt;
✅ Permission Check&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How Spring Security Uses Them
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Whenever a request enters a Spring Boot application:&lt;/strong&gt;&lt;br&gt;
Request&lt;br&gt;
   ↓&lt;br&gt;
Authentication&lt;br&gt;
   ↓&lt;br&gt;
Authorization&lt;br&gt;
   ↓&lt;br&gt;
Controller&lt;/p&gt;

&lt;p&gt;First, Spring Security verifies the user.&lt;br&gt;
Then it checks whether the user has permission to access the requested resource.&lt;br&gt;
Only after both checks pass does the request reach the controller.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Big Takeaway
&lt;/h2&gt;

&lt;p&gt;Authentication and Authorization work together, but they solve different problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authentication confirms your identity.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Authorization determines your permissions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A simple way to remember:&lt;br&gt;
Authentication = Who are you?&lt;br&gt;
Authorization = What can you do?&lt;/p&gt;

&lt;p&gt;Once I understood this difference, many Spring Security concepts became much easier to understand. I hope this explanation helps you too.&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>springsecurity</category>
      <category>backend</category>
    </item>
    <item>
      <title>What Happens Before Your API Receives a Request in Spring Security?</title>
      <dc:creator>sonali kumari shahi</dc:creator>
      <pubDate>Tue, 02 Jun 2026 11:22:32 +0000</pubDate>
      <link>https://dev.to/sonalishahi/what-happens-before-your-api-receives-a-request-in-spring-security-2lmc</link>
      <guid>https://dev.to/sonalishahi/what-happens-before-your-api-receives-a-request-in-spring-security-2lmc</guid>
      <description>&lt;p&gt;When I first added Spring Security to my Spring Boot project, something surprising happened.&lt;br&gt;
All my APIs were suddenly protected, and I could no longer access them without authentication.&lt;br&gt;
At first, it felt like magic. 😄&lt;/p&gt;

&lt;p&gt;But then I wondered:&lt;/p&gt;
&lt;h2&gt;
  
  
  What actually happens when a request enters a Spring Security application?
&lt;/h2&gt;

&lt;p&gt;In this blog, we'll follow the complete journey of a request and understand how Spring Security protects our application behind the scenes.&lt;/p&gt;
&lt;h2&gt;
  
  
  A Request's Journey Through Spring Security
&lt;/h2&gt;

&lt;p&gt;Let's say a user sends a request to access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;GET /api/customers
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might think the request goes directly to the controller.&lt;br&gt;
But that's not true.&lt;br&gt;
Before your controller sees the request, Spring Security steps in and starts asking a few important questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First Question: "Who Are You?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The request arrives at Spring Security's filter chain.&lt;/p&gt;

&lt;p&gt;At this point, Spring Security tries to identify the user.&lt;/p&gt;

&lt;p&gt;It looks for credentials such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Username and Password&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JWT Token&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;OAuth Credentials&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If no credentials are found, Spring Security stops the request right there.&lt;/p&gt;

&lt;p&gt;The controller never gets a chance to handle it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second Question: "Are These Credentials Valid?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If credentials are present, Spring Security verifies them.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Is the username correct?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Does the password match?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Is the JWT token valid and not expired?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the verification fails, the request is rejected.&lt;/p&gt;

&lt;p&gt;Only valid users can move to the next stage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Third Question: "What Are You Allowed To Access?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now Spring Security knows who the user is.&lt;/p&gt;

&lt;p&gt;But being authenticated doesn't automatically mean you can access everything.&lt;/p&gt;

&lt;p&gt;Suppose a user tries to access an admin endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/admin/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spring Security checks the user's roles and permissions.&lt;/p&gt;

&lt;p&gt;If the user has the required authority, the request moves forward.&lt;/p&gt;

&lt;p&gt;Otherwise, access is denied.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finally, The Request Reaches The Controller&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Only after passing all security checks does the request reach your controller.&lt;/p&gt;

&lt;p&gt;Request&lt;br&gt;
   ↓&lt;br&gt;
Spring Security&lt;br&gt;
   ↓&lt;br&gt;
Authentication&lt;br&gt;
   ↓&lt;br&gt;
Authorization&lt;br&gt;
   ↓&lt;br&gt;
Controller&lt;/p&gt;

&lt;p&gt;At this point, your business logic starts executing and a response is generated.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Big Takeaway
&lt;/h2&gt;

&lt;p&gt;One thing that surprised me while learning Spring Security was that the controller is actually the last stop in the journey.&lt;/p&gt;

&lt;p&gt;Before a request reaches your API, Spring Security has already:&lt;/p&gt;

&lt;p&gt;✅ Identified the user&lt;/p&gt;

&lt;p&gt;✅ Verified the credentials&lt;/p&gt;

&lt;p&gt;✅ Checked permissions&lt;/p&gt;

&lt;p&gt;✅ Decided whether the request should be allowed&lt;/p&gt;

&lt;p&gt;That's why Spring Security is such an important part of modern backend applications.&lt;/p&gt;

&lt;p&gt;It acts as a protective layer between users and your business logic, making sure only the right people can access the right resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Spring Security topic would you like to see next?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🔹 Authentication vs Authorization&lt;br&gt;
🔹 Security Filter Chain&lt;br&gt;
🔹 JWT Authentication&lt;br&gt;
🔹 UserDetailsService&lt;/p&gt;

&lt;p&gt;Let me know in the comments! 🚀&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>backend</category>
      <category>java</category>
      <category>springsecurity</category>
    </item>
  </channel>
</rss>
