From f0001c5c8d8a33729b93d8d6e10d3af40bfabed6 Mon Sep 17 00:00:00 2001 From: Kamal Wickramanayake Date: Sat, 13 Jun 2026 21:03:31 +0530 Subject: Added sample application 09-spring-security-db-authentication --- .../09-spring-security-db-authentication/README | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spring-boot/09-spring-security-db-authentication/README (limited to 'spring-boot/09-spring-security-db-authentication/README') diff --git a/spring-boot/09-spring-security-db-authentication/README b/spring-boot/09-spring-security-db-authentication/README new file mode 100644 index 0000000..6e50354 --- /dev/null +++ b/spring-boot/09-spring-security-db-authentication/README @@ -0,0 +1,23 @@ +This sample project shows how to authenticate users based on credentials maintained in a Postgresql database. + +Passwords are hashed using Argon2. Look at the SecurityConfig.java for Argon2 input parameters used. + +To run with support for hot swap during development, use the dev profile as follows: + + mvn spring-boot:run -Dspring-boot.run.profiles=dev + +User/Pasword (as defined in resources/data.sql) + + admin: abc123 + user1: abc123 + +Key points: + +1. pom.xml dependencies +2. config/SecurityConfig.java - Can be used to modify Spring Security behavior. +3. user package Java source files + - serivice/CustomUserDetailsService.java is the key source file that defines a UserDetailsService bean that fetches user details from UserRepository (which fetches data from database using JPA) + +Misc: + +Online Argon2 hash generator: https://argon2.online/ \ No newline at end of file -- cgit v1.2.3