Authentication Logic with SpringBoot Security (using hard-coded users)
see this article Authentication and Authorization in Spring Boot 3.0 with Spring Security
-
John
- name: john
- password: 2033
- role: USER & ADMIN
-
Maria
- name: Maria
- password: 3344
- role: USER
- Now, with that in mind you can perform request to the controller
- First you need to clone this to your machine
git clone https://github.com/DevDario/basicAuth
- Then access it
cd basicAuth/
- Now you can build the project:
$ ./mvnw clean package
- and then run it:
$ java -jar target/basicAuth-0.0.1-SNAPSHOT.jar
You can access the API here: localhost:8080.
You will be redirected to the login form
You can also access the not-secure endpoint at: localhost:8080/welcome.
$ http GET :8080/login
if you're already authenticated(as a USER) you can hit this URL:
$ http GET :8080/auth/user/userProfile
And if you're already authenticated(as a ADMIN) you can hit this URL:
$ http GET :8080/auth/admin/adminProfile