https://github.com/andersonhsporto/jwtexample
Example of JWT token in spring security 6
https://github.com/andersonhsporto/jwtexample
docker gradle java java-17 jpa jwt lombok postgresql spring-boot spring-security
Last synced: about 2 months ago
JSON representation
Example of JWT token in spring security 6
- Host: GitHub
- URL: https://github.com/andersonhsporto/jwtexample
- Owner: andersonhsporto
- Created: 2023-06-23T20:56:47.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-23T20:56:51.000Z (almost 2 years ago)
- Last Synced: 2025-01-17T05:28:56.089Z (3 months ago)
- Topics: docker, gradle, java, java-17, jpa, jwt, lombok, postgresql, spring-boot, spring-security
- Language: Java
- Homepage:
- Size: 65.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Jwt Example
## Description
This is a simple example of how to use JWT in spring security 6.
## Technologies
- [Java 17](https://www.java.com/pt-BR/) - Programming language
- [Spring Boot 3.1.1](https://spring.io/projects/spring-boot) - MVC Framework
- [Spring Security 6.0.0](https://spring.io/projects/spring-security) - Security Framework
- [Spring Data JPA 3.2.1](https://spring.io/projects/spring-data-jpa) - Data access framework
- [Postgres 13](https://www.postgresql.org/) - Database
- [Gradle](https://gradle.org/) - Build tool
- [Docker](https://www.docker.com/) - Containerization platform## How to run
1. Clone this repository
2. Start a local postgres database or use docker-compose to start one
2. Run `gradle bootRun`### Docker
To start a postgres database using docker-compose, run the following command:
```shell
docker-compose up -d
```## How to test
To register a new user, send a POST request to `http://localhost:8080/api/v1/user/register` with the following body:
```json
{
"firstName": "firstName",
"lastName": "lastName",
"email": "{valid-email}",
"password": "{password}"
}
```This will return a 201 status code if the user was created successfully and return a jwt token
in the response header and body.To authenticate, send a POST request to `http://localhost:8080/api/v1/user/authenticate` with the following body:
```json
{
"email": "{valid-email}",
"password": "{password}"
}
```## Contact Information
If you have any questions, suggestions, or critiques, please contact me using [email](mailto:[email protected])
or through [LinkedIn](https://www.linkedin.com/in/andersonhsporto/).