<?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: kumar ramanathan</title>
    <description>The latest articles on DEV Community by kumar ramanathan (@kumar_ramanathan_bab6f809).</description>
    <link>https://dev.to/kumar_ramanathan_bab6f809</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%2F3103518%2F326ab178-06f7-42ed-996b-af5fb55174da.png</url>
      <title>DEV Community: kumar ramanathan</title>
      <link>https://dev.to/kumar_ramanathan_bab6f809</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kumar_ramanathan_bab6f809"/>
    <language>en</language>
    <item>
      <title>Rest api 3: Create Item in store</title>
      <dc:creator>kumar ramanathan</dc:creator>
      <pubDate>Wed, 11 Feb 2026 14:13:45 +0000</pubDate>
      <link>https://dev.to/kumar_ramanathan_bab6f809/rest-api-3-create-item-in-store-pc1</link>
      <guid>https://dev.to/kumar_ramanathan_bab6f809/rest-api-3-create-item-in-store-pc1</guid>
      <description>&lt;p&gt;Requirement:&lt;br&gt;
We have list stores , need to append item from the rest api end point using path param input as store name and item in request body.&lt;/p&gt;

&lt;p&gt;our new method will be below for this case:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.post("/stores/&amp;lt;string:store_name&amp;gt;/items")
def create_item_in_store(store_name):
    request_data = request.get_json()
    for store in stores:
        if store["name"] == store_name:
            new_item = {"name": request_data["name"], "price": request_data["price"]}
            store["items"].append(new_item)
            return new_item, 201
    return {"message": "store not found"}, 404
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in post man using the below url and input hit the api end point :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikze2lmlhxxs2gjch21x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fikze2lmlhxxs2gjch21x.png" alt=" " width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now again retrieve all the data:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw4t48mee5yfpysccahbs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw4t48mee5yfpysccahbs.png" alt=" " width="800" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we will try to add more then one item in to the request, to access more than one item we need to modify our code logic little bit&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.post("/stores/&amp;lt;string:store_name&amp;gt;/items")
def create_items_in_store(store_name):
    request_data = request.get_json()
    for store in stores:
        if store["name"] == store_name:
            for item in request_data["items"]:
                new_item = {"name": item["name"], "price": item["price"]}
                store["items"].append(new_item)
            return {"message": "items created"}, 201
    return {"message": "store not found"}, 404
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpc14tkvo8axst1oxo16r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpc14tkvo8axst1oxo16r.png" alt=" " width="800" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now hit the get stores again &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyivnq9r1yt6wtxkuptdk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyivnq9r1yt6wtxkuptdk.png" alt=" " width="800" height="492"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flask</category>
      <category>python</category>
    </item>
    <item>
      <title>Rest API 2: Create Store and retrieve all stores</title>
      <dc:creator>kumar ramanathan</dc:creator>
      <pubDate>Tue, 10 Feb 2026 14:10:11 +0000</pubDate>
      <link>https://dev.to/kumar_ramanathan_bab6f809/rest-api-2-create-store-and-retrieve-all-stores-22gi</link>
      <guid>https://dev.to/kumar_ramanathan_bab6f809/rest-api-2-create-store-and-retrieve-all-stores-22gi</guid>
      <description>&lt;p&gt;Requirement:&lt;br&gt;
Need to create a new store in our My store. &lt;/p&gt;

&lt;p&gt;Scenario1:&lt;br&gt;
We create a dummy post method in our code with pass , try to hit from post man using post request and see what is the response flask provides.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask,app
app = Flask(__name__)

stores = [
    {
    "name": "my store",
    "items": [
        {"name": "my item",
            "price": 15.99
        }
    ]
}
]

@app.get("/stores")
def get_stores():
    return stores

@app.post("/stores")    
def create_store():
    pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzcyq2l9gera43hu6gy06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzcyq2l9gera43hu6gy06.png" alt=" " width="800" height="504"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we see we are getting 500  internal server error. This is due to Flask always expects a response.&lt;/p&gt;

&lt;p&gt;Scenario 2:&lt;br&gt;
Now change the code snippet to below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.post("/stores")    
def create_store():
    pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart the server and hot from post man you get below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92moppxcfazivh7qmzdf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92moppxcfazivh7qmzdf.png" alt=" " width="800" height="329"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Scenario 3:&lt;br&gt;
Now add a code to add the incoming data from post request to the stores in our app and show it back.&lt;/p&gt;

&lt;p&gt;For this one to read the inputs from the request , we need to import request from flask like below. After using the request object read the values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, request
app = Flask(__name__)

stores = [
    {
    "name": "my store",
    "items": [
        {"name": "my item",
            "price": 15.99
        }
    ]
}
]

@app.get("/stores")
def get_stores():
    return stores

@app.post("/stores")    
def create_store():
   request_data = request.get_json()
   new_store = { "name": request_data["name"], "items": []}
   stores.append(new_store)
   return new_store, 201  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1url50xrqf1vgnn4yvu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1url50xrqf1vgnn4yvu9.png" alt=" " width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now hit our get endpoint&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqsfs9yoizxs6lk0iqvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqsfs9yoizxs6lk0iqvs.png" alt=" " width="800" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>backend</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>First Rest api end point</title>
      <dc:creator>kumar ramanathan</dc:creator>
      <pubDate>Mon, 09 Feb 2026 14:20:47 +0000</pubDate>
      <link>https://dev.to/kumar_ramanathan_bab6f809/first-rest-api-end-point-1b9b</link>
      <guid>https://dev.to/kumar_ramanathan_bab6f809/first-rest-api-end-point-1b9b</guid>
      <description>&lt;p&gt;&lt;strong&gt;Requirement:&lt;/strong&gt;&lt;br&gt;
Create a stores list with a dictionary of stores and items. items is again a list with dictionary of name and price.&lt;br&gt;
Create a method which has a get endpoint to get the stores details in the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask,app
app = Flask(__name__)

stores = [
    {
    "name": "my store",
    "items": [
        {"name": "my item",
            "price": 15.99
        }
    ]
}
]

@app.get("/stores")
def get_stores():
    return stores
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the code in the VS code editor.&lt;/p&gt;

&lt;p&gt;In your venv , run flask and hit the browser or post man with the URL&lt;br&gt;
&lt;a href="http://127.0.0.1:5000/stores" rel="noopener noreferrer"&gt;http://127.0.0.1:5000/stores&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;you get below output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fybqhi25wn1y6z5ac5zc1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fybqhi25wn1y6z5ac5zc1.png" alt=" " width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>backend</category>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>Python Flask set up in VS Code windows 11</title>
      <dc:creator>kumar ramanathan</dc:creator>
      <pubDate>Mon, 09 Feb 2026 13:52:28 +0000</pubDate>
      <link>https://dev.to/kumar_ramanathan_bab6f809/python-flask-set-up-in-vs-code-windows-11-459i</link>
      <guid>https://dev.to/kumar_ramanathan_bab6f809/python-flask-set-up-in-vs-code-windows-11-459i</guid>
      <description>&lt;h2&gt;
  
  
  Install VS Code and python
&lt;/h2&gt;

&lt;p&gt;UVS Code : sing Microsoft installer from the page: &lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;https://code.visualstudio.com/download&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Python: &lt;a href="https://www.python.org" rel="noopener noreferrer"&gt;https://www.python.org&lt;/a&gt; › downloads&lt;/p&gt;

&lt;p&gt;step 1 : Set up new VSCode project&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a folder Mystore in documents&lt;/li&gt;
&lt;li&gt;Open that folder in vscode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Step 2:open terminal in terminal -&amp;gt; new terminal&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;click on + sign&lt;/li&gt;
&lt;li&gt;choose cmd for windows &lt;/li&gt;
&lt;li&gt;type command python -m venv .venv&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fckcj97vsly6jlprdiqsp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fckcj97vsly6jlprdiqsp.png" alt=" " width="800" height="63"&gt;&lt;/a&gt;&lt;br&gt;
Now you all set with virtual enviornment&lt;/p&gt;

&lt;p&gt;Note: Make sure next you enable the Microsoft extension for python by clicking ctr+shift+x&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fld0zn467tn2x0x8d1ihv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fld0zn467tn2x0x8d1ihv.png" alt=" " width="467" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;step 3: Now setting interpreter&lt;br&gt;
type ctrl+shift+p , search interpreter , choose python recommended version&lt;/p&gt;

&lt;p&gt;step 4: Install flask&lt;br&gt;
python -m pip install flask&lt;/p&gt;

&lt;p&gt;Note: if you unable to find the installed flask libs under venv , possibly it is installed in your python installation folder. If so follow below.&lt;/p&gt;

&lt;p&gt;(.venv) C:\Users\kumar\Documents\2026\Minimal execution plan\mypthon\Mystore&amp;gt;rmdir /s /q .venv&lt;/p&gt;

&lt;p&gt;(.venv) C:\Users\kumar\Documents\2026\Minimal execution plan\mypthon\Mystore&amp;gt;python -m venv .venv&lt;/p&gt;

&lt;p&gt;(.venv) C:\Users\kumar\Documents\2026\Minimal execution plan\mypthon\Mystore&amp;gt;.venv\Scripts\activate&lt;/p&gt;

&lt;p&gt;(.venv) C:\Users\kumar\Documents\2026\Minimal execution plan\mypthon\Mystore&amp;gt;python -m pip install flask&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxl6xrkcy7k98s8wqbeuz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxl6xrkcy7k98s8wqbeuz.png" alt=" " width="280" height="677"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Step 5: Run flask&lt;br&gt;
(.venv) C:\Users\kumar\Documents\2026\Minimal execution plan\mypthon\Mystore&amp;gt;flask run                  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
** * Running on &lt;a href="http://127.0.0.1:5000" rel="noopener noreferrer"&gt;http://127.0.0.1:5000&lt;/a&gt;
Press CTRL+C to quit**&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you see above flask server started in the above URL.&lt;/p&gt;

&lt;p&gt;Step 6: Stop flask&lt;br&gt;
give ctl+c&lt;/p&gt;

</description>
      <category>python</category>
      <category>installation</category>
      <category>flask</category>
    </item>
    <item>
      <title>Spring Security Basic Authentication</title>
      <dc:creator>kumar ramanathan</dc:creator>
      <pubDate>Tue, 29 Apr 2025 10:52:14 +0000</pubDate>
      <link>https://dev.to/kumar_ramanathan_bab6f809/spring-security-basic-authentication-44jb</link>
      <guid>https://dev.to/kumar_ramanathan_bab6f809/spring-security-basic-authentication-44jb</guid>
      <description>&lt;p&gt;Spring security can be implemented in many ways. Common ways are&lt;br&gt;
a. basic authentication &lt;br&gt;
b. form based authentication&lt;br&gt;
c. digest authentication&lt;br&gt;
d. oauth authentication&lt;br&gt;
e. ldap authentication&lt;br&gt;
f. JWT authentication&lt;br&gt;
g. SAML authentication&lt;/p&gt;

&lt;p&gt;Basic authentication is used for test application , apis with low level security is needed. Here username and password is encoded in base4 format. No encryption operation.&lt;/p&gt;

&lt;p&gt;How to implement a simple basic authentication.&lt;/p&gt;

&lt;p&gt;step1: include gradle dependency "'org.springframework.boot:spring-boot-starter-security'"&lt;/p&gt;

&lt;p&gt;Create a spring security configuration class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
public class SecurityWebConfig {
    @Bean
    public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception{
        httpSecurity.authorizeHttpRequests(
                auth -&amp;gt; auth.requestMatchers("/hello").authenticated()
                        .anyRequest().authenticated())
                .httpBasic(Customizer.withDefaults());
        return httpSecurity.build();
    }

    @Bean
    public InMemoryUserDetailsManager userDetailsService() {
        UserDetails user = User.withUsername("user")
                .password(passwordEncoder().encode("password"))
                .roles("USER")
                .build();
        return new InMemoryUserDetailsManager(user);
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }


}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the flow will work in this way !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvf27kgniq1fc6qe8bsra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvf27kgniq1fc6qe8bsra.png" alt=" " width="800" height="633"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead inMemoryUserDetailsManager we can use : JdbcUserDetailsManager to get details from a DB.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Spring Security</title>
      <dc:creator>kumar ramanathan</dc:creator>
      <pubDate>Tue, 29 Apr 2025 01:22:11 +0000</pubDate>
      <link>https://dev.to/kumar_ramanathan_bab6f809/spring-security-3kfn</link>
      <guid>https://dev.to/kumar_ramanathan_bab6f809/spring-security-3kfn</guid>
      <description>&lt;p&gt;What is spring security ?&lt;br&gt;
Spring Security is a framework helps to protect web apps, apis, MVC applications from external security issues. It helps to authenticate , authorize, protect the app from externals hackers.&lt;/p&gt;

&lt;p&gt;Authenticate:&lt;br&gt;
Identify the user is a valid user to enter/use our application.&lt;/p&gt;

&lt;p&gt;Authorization:&lt;br&gt;
Identified user's permission to access a particular resource inside the application.&lt;/p&gt;

&lt;p&gt;In spring boot we have a Gradle/maven dependency 'org.springframework.boot:spring-boot-starter-security' helps to add spring security feature in our application.&lt;/p&gt;

&lt;p&gt;By default we have added the "form based authentication" , it prompts for user name and password . &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzwvgjst2j05zk3opvvq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhzwvgjst2j05zk3opvvq.png" alt=" " width="477" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Default user name is user, password get from the spring boot application started terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj7qakdbwujzyigd8w4y1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj7qakdbwujzyigd8w4y1.png" alt=" " width="728" height="185"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Spring security filters:&lt;br&gt;
When a http requests comes it will land in set of filter chain which handles the security operations. Below Diagram shows the flow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mtg9pabzd8k9acumw7e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mtg9pabzd8k9acumw7e.png" alt=" " width="407" height="562"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a spring mvc application,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Client send the request to tomcat servlet container&lt;/li&gt;
&lt;li&gt;Container sends the http request to dispatcher servlet in the format of http servlet.&lt;/li&gt;
&lt;li&gt;Dispatcher servlet with help of handler mapping , transfers the request to controller&lt;/li&gt;
&lt;li&gt;After dispatcher servlet using view resolver send the data back to tomcat container
5.Tomcat container converts the servlet response to http response and send it to client&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffetid0uzxfb8mtlw9m0c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffetid0uzxfb8mtlw9m0c.png" alt=" " width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the filter chain is created by Tomcat which contains the filters responsible to map the request to dispatcher servlet. Dispatcher servlet will do all remaining.&lt;/p&gt;

&lt;p&gt;Filters as in above diagram can be a single filter/ filter chain that will be handled by servlet api.&lt;/p&gt;

&lt;p&gt;DelegatingFilterProxy&lt;/p&gt;

&lt;p&gt;The management of filters will be handed over to spring IOC container through a filter called DelegatingFilterProxy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fv28u62k0pjh5krlcy9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9fv28u62k0pjh5krlcy9.png" alt=" " width="437" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;FilterChainProxy&lt;/p&gt;

&lt;p&gt;FilterChainProxy is a special type of filter provided by spring security helps to delegate multiple filters using the class securityfilterchain &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74m96m8mqiel3dfp0739.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F74m96m8mqiel3dfp0739.png" alt=" " width="747" height="628"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Securityfilterchain:&lt;br&gt;
Securityfilterchain is used by filterchainproxy to identify which security  filter should be invoked to handle the current request.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzk7hizidmzqyjoe9pxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyzk7hizidmzqyjoe9pxr.png" alt=" " width="800" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Even we have multiple security filter chains , filterchain proxy identify which secuirtyfilter chain should be used.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3q0fiay80nb4kqk2bp8f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3q0fiay80nb4kqk2bp8f.png" alt=" " width="800" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basic Flow of Spring security:&lt;br&gt;
Basically the https request passed to securityfilterchain, filter communicates with Authentication manager object which contains authorize method , which in turn communicates with Authentaicationproviders provided by spring (LDAPauthentication provider,oauthauthenticationprovider,daoauthenticationprovider) , which in turn calls the userdetails object which has implementations for "cachinguserdetailsservice", "inmemoryuserdetailsservice","JDBCdaoImpl"&lt;br&gt;
service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7u0v90uy6nvnmnczt7c9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7u0v90uy6nvnmnczt7c9.png" alt=" " width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

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