A backend project focused on implementing user authentication and authorization using the Spring Boot framework. It provides a REST API for user login and signup functionality, with security features and web tokens (JWT) for authentication.
-
User signup: Users can create new accounts by providing their details such as name, email, and password. The user information is securely stored in the H2 database.
-
User login: Users can authenticate themselves by providing their credentials (email and password) through the login endpoint. Upon successful authentication, a web token is generated and returned.
-
JWT-based authentication: The application uses JSON Web Tokens (JWT) to authenticate and authorize users. The generated token is required to access protected resources, ensuring that only authenticated users can access them.
- JAVA
- SPRING
- SPRINGBOOT
- MAVEN
- H2 DATABASE
- POSTMAN
- SPRING DATA JPA
- SPRING BOOT DEVTOOLS
- SPRING WEB
- SPRING SECURITY
- H2 DATABASE
- VALIDATION
- LOMBOK
- JWT API
- JWT IMPL
- JWT JACKSON
Before running the application, make sure you have the following installed:
- Java
- Java IDE (preferably Spring Tool Suite)
Install the Spring Tool Suite (STS)
https://spring.io/toolsClone the Repository
git clone https://github.com/sahu-neha/Backend-Authentication-SpringBoot.gitGo to the Project Directory
Open the Backend_for_login_signup Folder with STSGo to src/main/resources > application.properties & change your SpringBoot username and password
(By default, Spring Boot configures the application to connect to an in-memory store with the username "sa" and an empty password)
spring.datasource.username=sa
spring.datasource.password=passwordTo change the Server Port
server.port=8080Go to com.masai package > BackendForLoginSignupApplication.java
Run as Spring Boot App (Alt+Shift+X, B)Open Postman and navigate to the following URLs:
-
Home:
Method:
GEThttp://localhost:8080/user
-
User Signup:
http://localhost:8080/user/signup
Method:
POST
Request Body:{ "firstName": "fName", "lastName": "lName", "email": "email@example.com", "password": "@password" } -
Admin Signup:
http://localhost:8080/user/signup/{secretKey}Replace
{secretKey}with the actual secret key value.Method:
POST
Request Body:{ "firstName": "fName", "lastName": "lName", "email": "email@example.com", "password": "@password" } -
User Login:
http://localhost:8080/user/userLogin
Method:
GET
Request Body:{ "email": "email@example.com", "password": "@password" } -
Admin Login:
http://localhost:8080/user/adminLogin
Method:
GET
Request Body:{ "email": "email@example.com", "password": "@password" }
These URLs represent different endpoints of the backend API. By running them you can interact with the corresponding functionalities of the application.
This backend project provides user authentication and authorization using Spring Boot, with features such as user signup, login, and JWT-based authentication.
