Skip to main content

Mini Project: Role-based API Security (Basic Auth)

Learn Mini Project: Role-based API Security (Basic Auth) (Spring Security, Spring Boot) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Mini Real-Time Project: Role-based API Security (Basic Auth) Problem An API has a public page, a members-only page and an admin-only page. Anonymous visitors must get 401, normal users 403 on the admin page, and passwords must never be stored in plain text. Requirements Define users with BCrypt-hashed passwords. Permit /public/**, require a login for everything else, and the ADMIN role for /admin/**. Start the application on a free port. Call it with no credentials, wrong credentials, a normal user and an admin, and print each status. Concepts Used SecurityFilterChain authorizeHttpRequests...

More lessons in Spring Security