Skip to content

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.

Notifications You must be signed in to change notification settings

sahu-neha/Backend-Authentication-SpringBoot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JWT Authentication

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.

banner

Table of Contents

Features

  • 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.

Tech-Stack

  • JAVA
  • SPRING
  • SPRINGBOOT
  • MAVEN
  • H2 DATABASE
  • POSTMAN

Dependencies

  • SPRING DATA JPA
  • SPRING BOOT DEVTOOLS
  • SPRING WEB
  • SPRING SECURITY
  • H2 DATABASE
  • VALIDATION
  • LOMBOK
  • JWT API
  • JWT IMPL
  • JWT JACKSON

Prerequisites

Before running the application, make sure you have the following installed:

  • Java
  • Java IDE (preferably Spring Tool Suite)

Setting & Installation

Install the Spring Tool Suite (STS)

https://spring.io/tools

Clone the Repository

git clone https://github.com/sahu-neha/Backend-Authentication-SpringBoot.git

Run Locally

Go to the Project Directory

Open the Backend_for_login_signup Folder with STS

Go 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=password

To change the Server Port

server.port=8080

Go to com.masai package > BackendForLoginSignupApplication.java

Run as Spring Boot App (Alt+Shift+X, B)

URL

Open Postman and navigate to the following URLs:

  1. Home:

    Method: GET

    http://localhost:8080/user
  2. User Signup:

    http://localhost:8080/user/signup

    Method: POST
    Request Body:

    {
     "firstName": "fName",
     "lastName": "lName",
     "email": "email@example.com",
     "password": "@password"
    }
  3. 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"
    }
  4. User Login:

    http://localhost:8080/user/userLogin

    Method: GET
    Request Body:

    {
     "email": "email@example.com",
     "password": "@password"
    }
  5. 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.

Conclusion

This backend project provides user authentication and authorization using Spring Boot, with features such as user signup, login, and JWT-based authentication.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages