Basic Tutorial
Queries
Authentication and authorization are core concepts in security. Let’s explore them in detail.
🔹 Authentication: Confirms "Who are you?" (identity verification)
🔹 Authorization: Determines "What are you allowed to do?"
UserDetailsService
, AuthenticationManager
SecurityFilterChain
or annotations like @PreAuthorize
By default, Spring Security provides an in-memory user. But in real applications, we authenticate users from a database.
Table name : user
id | username | password | role |
---|---|---|---|
1 | John | $2a$12$PypIq6C.MQ4dPia2piWMZO5vZIq2OFqmA4x9YAtm11ndY6VrfdUZy (john@123) | ADMIN |
2 | Mike | $2a$12$fv/xTvNU0S9LoQQo2nTPLurmuMSRlYmYP.DPRjLLHbJQjw9RZ4wcq (mike@123) | USER |
Bcrypt password generated here
UserDetailsService
This tells Spring Security how to fetch user details from the database.
SecurityConfig
Once the application is running, test the endpoints:
GET:http://localhost:8080/public/search
GET:http://localhost:8080/admin
GET:http://localhost:8080/user