https://github.com/avinash4231/authentication-on-restapi-using-spring-boot
Implement authentication for a Student CRUD REST API using Spring Boot. Secure endpoints with Spring Security, ensuring only authorized users can perform create, read, update, and delete operations.
https://github.com/avinash4231/authentication-on-restapi-using-spring-boot
authentication crud-operation hibernate jpa jwt rest-api spring-boot
Last synced: 2 months ago
JSON representation
Implement authentication for a Student CRUD REST API using Spring Boot. Secure endpoints with Spring Security, ensuring only authorized users can perform create, read, update, and delete operations.
- Host: GitHub
- URL: https://github.com/avinash4231/authentication-on-restapi-using-spring-boot
- Owner: Avinash4231
- Created: 2024-03-29T10:48:39.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-20T09:30:04.000Z (about 2 years ago)
- Last Synced: 2024-05-20T10:34:41.904Z (about 2 years ago)
- Topics: authentication, crud-operation, hibernate, jpa, jwt, rest-api, spring-boot
- Language: Java
- Homepage:
- Size: 80.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Authentication on Student CRUD REST API using Spring Boot
### Overview
This project demonstrates how to implement authentication for a Student CRUD (Create, Read, Update, Delete) REST API using Spring Boot. The application ensures that only authorized users can access and manipulate student records.
### Features
CRUD Operations: Create, Read, Update, and Delete student records.
Authentication: Secure API endpoints using Spring Security.
Database Integration: Use H2 in-memory database for development and testing.
### Technologies Used
Spring Boot
Spring Security
Spring Data JPA
H2 Database
Java
Maven
### Prerequisites
Java 8 or higher
Maven 3.6.0 or higher
Docker (optional, for containerization)
Setup Instructions
##### Clone the Repository
```
git clone https://github.com/yourusername/studentcrud-auth-api.git
cd studentcrud-auth-api
```
##### Build the Project
```
mvn clean install
```
##### Run the Application
```
mvn spring-boot:run
```
##### Access the API
The API will be accessible at http://localhost:8080/api/students.
Authentication
This application uses Spring Security to protect the API endpoints. You need to provide valid credentials to access the endpoints.
Default Credentials
Username: user
Password: password
Example Requests
##### Create a Student
```
curl -X POST -u user:password -H "Content-Type: application/json" -d '{"name": "John Doe", "email":"xyz@gmail.com", "course":"B.tech", "branch":"CSE"}'
http://localhost:8080/api/students
```
##### Get All Students
```
curl -X GET -u user:password http://localhost:8080/api/students
```
##### Get a Student by ID
```
curl -X GET -u user:password http://localhost:8080/api/students/{id}
```
##### Update a Student
```
curl -X PUT -u user:password -H "Content-Type: application/json" -d '{"name": "Jane Doe", "email":"Jane@gmail.com", "course":"B.tech", "branch":"CIVIL"}'
http://localhost:8080/api/students/{id}
```
##### Delete a Student
```
curl -X DELETE -u user:password http://localhost:8080/api/students/{id}
```