<?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: SURJENDU PAL</title>
    <description>The latest articles on DEV Community by SURJENDU PAL (@surjendu104).</description>
    <link>https://dev.to/surjendu104</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%2F947521%2F932d4cde-0007-4407-a408-cce489668c01.jpg</url>
      <title>DEV Community: SURJENDU PAL</title>
      <link>https://dev.to/surjendu104</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/surjendu104"/>
    <language>en</language>
    <item>
      <title>A Beginner's Guide to Flask App Development: Getting Started with Python's Microframework</title>
      <dc:creator>SURJENDU PAL</dc:creator>
      <pubDate>Fri, 26 Apr 2024 15:03:43 +0000</pubDate>
      <link>https://dev.to/surjendu104/a-beginners-guide-to-flask-app-development-getting-started-with-pythons-microframework-4bcl</link>
      <guid>https://dev.to/surjendu104/a-beginners-guide-to-flask-app-development-getting-started-with-pythons-microframework-4bcl</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9ugj21nqtwkhok6hmv9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9ugj21nqtwkhok6hmv9.png" alt="Python Flask Image" width="600" height="400"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Flask, known for its simplicity and flexibility, has become a popular choice for developing web applications in Python. Whether you're a seasoned developer or just starting your journey into web development, Flask offers a straightforward approach to building powerful and scalable applications. In this guide, we'll explore the basics of Flask app development, from installation to creating your first application, equipping you with the knowledge to kickstart your Flask journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installing Flask&lt;/strong&gt;&lt;br&gt;
Before diving into Flask development, you'll need to set up your development environment. First, ensure you have Python&lt;/p&gt;

&lt;p&gt;installed on your system. Then, you can install Flask using pip, Python's package installer. Open your terminal or command prompt and execute the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will download and install Flask along with its dependencies, making it available for use in your Python projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating Your First Flask Application&lt;/strong&gt;&lt;br&gt;
Now that Flask is installed, let's create a simple "Hello, World!" application to get started. Create a new Python file, for example, app.py, and open it in your preferred text editor or integrated development environment (IDE). Then, add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;

&lt;span class="c1"&gt;# Create a Flask application instance
&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Define a route and corresponding view function
&lt;/span&gt;&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello_world&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Hello, World!&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;# Run the Flask application
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;debug&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Save the file and return to your terminal or command prompt. Navigate to the directory containing &lt;code&gt;app.py&lt;/code&gt;, and execute the following command to run your Flask application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see output similar to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Congratulations!&lt;/strong&gt; You've created your first Flask application. Open a web browser and navigate to &lt;code&gt;http://127.0.0.1:5000/&lt;/code&gt; to see your "Hello, World!" message displayed in the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding Flask Routes&lt;/strong&gt;&lt;br&gt;
In the code snippet above, @app.route('/') is a decorator that associates the URL path '/' with the &lt;code&gt;hello_world()&lt;/code&gt; function. When a request is made to the root URL of your Flask application (&lt;a href="http://127.0.0.1:5000/"&gt;http://127.0.0.1:5000/&lt;/a&gt;), Flask invokes the &lt;code&gt;hello_world()&lt;/code&gt; function, which returns the string &lt;code&gt;'Hello, World!'&lt;/code&gt;. This string is then rendered as the response to the client's request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Expanding Your Flask Application&lt;/strong&gt;&lt;br&gt;
As you become more comfortable with Flask, you can start expanding your application by adding additional routes, views, templates, and functionality. Flask provides a flexible structure for organizing your application's code, allowing you to create modular and maintainable projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Flask's simplicity and ease of use make it an excellent choice for beginners and experienced developers alike. By following the steps outlined in this guide, you've taken the first steps towards mastering Flask app development. Experiment with different features, explore Flask's extensive documentation, and embark on your journey to building powerful web applications with Python and Flask. Happy coding!&lt;/p&gt;

</description>
      <category>python</category>
      <category>flask</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Transitioning from Spring Security WebMvcConfigurer to SecurityFilterChain: A Seamless Migration Guide</title>
      <dc:creator>SURJENDU PAL</dc:creator>
      <pubDate>Fri, 26 Apr 2024 14:52:35 +0000</pubDate>
      <link>https://dev.to/surjendu104/transitioning-from-spring-security-webmvcconfigurer-to-securityfilterchain-a-seamless-migration-guide-13e8</link>
      <guid>https://dev.to/surjendu104/transitioning-from-spring-security-webmvcconfigurer-to-securityfilterchain-a-seamless-migration-guide-13e8</guid>
      <description>&lt;p&gt;In the ever-evolving landscape of web development, keeping your security measures up-to-date is paramount. Spring Security has long been a go-to solution for securing Java applications, offering robust features and flexibility. Over time, Spring Security has evolved, introducing new paradigms and approaches to enhance security. One such evolution is the transition from &lt;code&gt;WebMvcConfigurer&lt;/code&gt; to &lt;code&gt;SecurityFilterChain&lt;/code&gt;, offering improved customization and better integration with modern web applications. In this guide, we'll explore the migration process from &lt;code&gt;WebMvcConfigurer&lt;/code&gt; to &lt;code&gt;SecurityFilterChain&lt;/code&gt;, empowering you to seamlessly upgrade your security configurations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding the Transition&lt;/strong&gt;&lt;br&gt;
Before diving into the migration process, let's briefly understand the key differences between &lt;code&gt;WebMvcConfigurer&lt;/code&gt; and &lt;code&gt;SecurityFilterChain&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WebMvcConfigurer&lt;/code&gt;: In earlier versions of Spring Security, developers typically used &lt;code&gt;WebMvcConfigurer&lt;/code&gt; to configure security for web applications. It provided methods for customizing security filters, intercept URLs, and configure authentication and authorization rules.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SecurityFilterChain&lt;/code&gt;: With the evolution of Spring Security, particularly in Spring Security 5.x, the introduction of &lt;code&gt;SecurityFilterChain&lt;/code&gt; marked a shift towards a more modular and flexible approach to security configuration. SecurityFilterChain allows developers to define security configurations at a more granular level, enabling better integration with various parts of the application stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Migration Steps&lt;/strong&gt;&lt;br&gt;
Now, let's delve into the steps involved in migrating from &lt;code&gt;WebMvcConfigurer&lt;/code&gt; to &lt;code&gt;SecurityFilterChain&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Review Existing Configuration&lt;/strong&gt;: Start by reviewing your existing security configuration implemented through &lt;code&gt;WebMvcConfigurer&lt;/code&gt;. Take note of the security filters, authentication providers, and any custom configurations you've defined.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update Dependencies&lt;/strong&gt;: Ensure that you're using a version of Spring Security that supports &lt;code&gt;SecurityFilterChain&lt;/code&gt;. Update your project's dependencies to the latest version of Spring Security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Define &lt;code&gt;SecurityFilterChain&lt;/code&gt; Beans&lt;/strong&gt;: In your application's configuration class, typically annotated with @EnableWebSecurity, define &lt;code&gt;SecurityFilterChain&lt;/code&gt; beans. Each bean represents a chain of security filters for a specific set of URLs or paths. You can define multiple &lt;code&gt;SecurityFilterChain&lt;/code&gt; beans to handle different security requirements across various parts of your application.
java
Copy code
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Configuration&lt;/span&gt;
&lt;span class="nd"&gt;@EnableWebSecurity&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SecurityConfig&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;WebSecurityConfigurerAdapter&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpSecurity&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;http&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;authorizeRequests&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;antMatchers&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/public/**"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;permitAll&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;anyRequest&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;authenticated&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;and&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;formLogin&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;loginPage&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/login"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;permitAll&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;and&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;logout&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;permitAll&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@Bean&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;SecurityFilterChain&lt;/span&gt; &lt;span class="nf"&gt;securityFilterChain&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HttpSecurity&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;http&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;authorizeRequests&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;antMatchers&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/admin/**"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;hasRole&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ADMIN"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;antMatchers&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/user/**"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;hasRole&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"USER"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;anyRequest&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;authenticated&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;and&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;formLogin&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;permitAll&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;and&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;logout&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;permitAll&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Customize SecurityFilterChain&lt;/strong&gt;: Within each &lt;code&gt;SecurityFilterChain&lt;/code&gt; bean, customize the security configuration as per your application's requirements. You can define authentication mechanisms, authorization rules, and other security filters within each chain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Testing and Validation&lt;/strong&gt;: Thoroughly test your application after migrating to &lt;code&gt;SecurityFilterChain&lt;/code&gt;. Ensure that all security features are functioning as expected. Conduct comprehensive testing to identify and address any potential issues or regressions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Migrating from &lt;code&gt;WebMvcConfigurer&lt;/code&gt; to &lt;code&gt;SecurityFilterChain&lt;/code&gt; represents a step forward in leveraging the capabilities of Spring Security for robust application security. By following the steps outlined in this guide, you can seamlessly transition your security configurations while benefiting from the enhanced flexibility and modularity offered by &lt;code&gt;SecurityFilterChain&lt;/code&gt;. Stay proactive in keeping your security measures up-to-date to ensure the integrity and resilience of your Java web applications.&lt;/p&gt;

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