Back to Browse

Spring Security 6 Database Authentication: From Login Request to Verified User

4.4K views
Nov 17, 2023
34:17

Most Spring Security tutorials hand you an in-memory user and call it "authentication." That's not production. In this video, we wire Spring Security 6 to a REAL database β€” and trace every step from the raw login request to a fully verified, authenticated user. πŸ” What you'll learn: β†’ How AuthenticationManager delegates to DaoAuthenticationProvider β†’ How UserDetailsService loads your user from the database β†’ How PasswordEncoder validates credentials securely β†’ The exact filter chain steps before authentication is confirmed β†’ How the Authentication object is built and stored in the SecurityContext β†’ Common production mistakes and how to avoid them This is NOT an in-memory user store tutorial. This is real database authentication β€” the way it works in production Spring Security 6 applications. πŸ“˜ Resources Mentioned: πŸ§‘β€πŸ’» Source Code: https://github.com/hello-iftekhar/Spring-JPA-Authentication.git πŸ” *Secure 3 Spring Boot endpoints in 30 minutes (free guide):* https://learnwithiftekhar.kit.com/secure-your-api-in-30-minutes πŸ‘‰ Master programming by recreating your favorite technologies: https://app.codecrafters.io/join?via=learnwithiftekhar πŸ™Š Here are the tools and resources I use in my videos: 🎢 Background sound: https://share.epidemicsound.com/ia954g 🌐 Secure your connection with NordVPN: https://nordvpn.sjv.io/o4zYan IDE I use for coding * IntelliJ Idea Ultimate * VsCode * Sublime *Note:* Some of the links in this description are affiliate links, and I may earn a small commission if you make a purchase through them. Thank you for your support. 🀚 In case you want to contact me: ❌ My LinkedIn profile: https://www.linkedin.com/in/hossain-md-iftekhar/ ❌ Github: https://github.com/learnwithiftekhar ❌ My Fiverr profile: https://www.fiverr.com/ifte_hsn I also provide service on Upwork. In case you are interested: ❌ https://www.upwork.com/freelancers/~0145597fbf5e701492 Contents: 0:00 Intro 0:18 What are we going to build 1:37 Create a new spring boot project 4:23 Connect to the MySQL database from Intelij IDE using the database tool 5:58 Configuring Spring Boot for database connection 11:03: Creating Model package 12:15: Creating User Model 14:43: Create Role Model 16:05: Run the project 16:31 Summery of created database tables 17:41 Creating Repository 19:12 Creating Security Config 20:05 Creating UserDetailsService 20:44 fingByUsername method in UserRepository 21:25 Implementing UserDetail interface in User model 21:48 implementing getAuthorities() Method 23:19 return user from loadUserByUsername method 23:57 Inject UserDetailsService in security Config 25:35 Seeding database 28:43 Password Hashing 29:48 Create controller 31:00 Create an "admin" endpoint in the controller 31:20 Create a "staff" endpoint in the controller 31:46 Restricting access to admin endpoint 32:00 Restricting access to staff endpoint 32:40 Adding staff user in the database 33:13 Run the project and see the final result #SpringSecurity6 #JPAAuthentication #Tutorial #StepByStep #Authentication #Security #JavaSpring #YouTubeTutorial #SoftwareDevelopment #WebDevelopment #JavaProgramming #ProgrammingTutorial #CodeTutorial #JavaDevelopment #AuthenticationTutorial #SpringBoot #JavaSecurity #JavaWeb #SpringFramework #SpringSecurity

Download

1 formats

Video Formats

360pmp450.1 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Spring Security 6 Database Authentication: From Login Request to Verified User | NatokHD