Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hemantdwivedi/authentication-system
This repo contains a Authentication System.
https://github.com/hemantdwivedi/authentication-system
authentication-backend java jwt-authentication jwt-bearer-tokens jwt-logout springsecurity-jwt
Last synced: 20 days ago
JSON representation
This repo contains a Authentication System.
- Host: GitHub
- URL: https://github.com/hemantdwivedi/authentication-system
- Owner: hemantDwivedi
- Created: 2023-08-05T14:05:33.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-06T19:30:53.000Z (over 1 year ago)
- Last Synced: 2024-10-05T04:21:38.564Z (about 1 month ago)
- Topics: authentication-backend, java, jwt-authentication, jwt-bearer-tokens, jwt-logout, springsecurity-jwt
- Language: Java
- Homepage:
- Size: 81.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Authentication System
This project is a simple authentication system. It demonstrate how to secure your APIs with spring security with JWT.
## Project Structure```css
├── src/
| ├── main/
| | ├── java/
| | | └── com.assignment.authenticationsystem/
| | | ├── config/
| | | ├── controllers/
| | | ├── dto/
| | | ├── exception/
| | | ├── models/
| | | ├── repository/
| | | ├── security/
| | | └── services/
| | | ├── token/
| | └── resources/
| | ├── static/
| | |── templates/
| | └── application.properties/
├── test/
├── pom.xml
└── README.md
```
## Prerequisites- Java 17
- Maven
- MySQL
- Postman or Talend API Tester
## Installation- Java Development Kit (JDK) 17 or higher: You can download the JDK from [Oracle](https://www.oracle.com/in/java/technologies/downloads/#:~:text=JDK%20Development%20Kit%2020.0.2%20downloads,x64_bin.rpm%20(sha256)%C2%A0(OL%208%20GPG%20Key))
### Getting the Source Code
Clone the repository using [Git](https://git-scm.com/)
- Run the following commands in your Terminal
```bash
git clone https://github.com/hemantDwivedi/authentication-system.gitcd authentication-system
```### Configure Database and Environment
1. Create a new database named ```'authentication_system'``` in your MYSQL.2. Open project folder in IntelliJ IDEA and wait till to download all neccessary dependencies.
3. Open the ```application.properties``` file located in the ```src/main/resources``` directory.
4. Update the database connection properties (e.g., ```spring.datasource.url, spring.datasource.username, spring.datasource.password```) to match your database configuration.
5. Right Click on AuthenticationSystemApplication.java located in the ```src/main/java/com.assignment.authenticationsystem``` and run the applcation.
Once the application is running, you can test APIs in your [Postman](https://www.postman.com/downloads/) or with chrome extention [Talend API Tester](https://chrome.google.com/webstore/detail/talend-api-tester-free-ed/aejoelaoggembcahagimdiliamlcdmfm).
## Use Cases
- To create a new user, make a ```POST``` request to ```/api/v1/register``` with user details (e.g. username, password, email) in the request body.
- To generate JWT Token, make a ```POST``` request to ```/api/v1/login```
- ```GET /api/v1/admin``` only accessible by ADMIN user.
- To logout, make a ```GET``` request to ```/api/v1/logout```. It will logged out user and invalidate the JWT token.
## Running Tests
To run tests, run the following command
```bash
mvn test
```This command will execute all the unit tests in the project, and the test results will be displayed in the console.