https://github.com/shaikrasheed99/springboot-security-jwt-authentication
JWT Authentication in Springboot.
https://github.com/shaikrasheed99/springboot-security-jwt-authentication
jwt jwt-authentication jwt-authorization spring-boot spring-jwt-authentication spring-security spring-security-jwt spring-security-jwt-spring-boot
Last synced: about 1 month ago
JSON representation
JWT Authentication in Springboot.
- Host: GitHub
- URL: https://github.com/shaikrasheed99/springboot-security-jwt-authentication
- Owner: shaikrasheed99
- License: mit
- Created: 2023-11-16T13:21:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-16T13:24:14.000Z (over 2 years ago)
- Last Synced: 2025-10-13T15:08:25.203Z (8 months ago)
- Topics: jwt, jwt-authentication, jwt-authorization, spring-boot, spring-jwt-authentication, spring-security, spring-security-jwt, spring-security-jwt-spring-boot
- Language: Java
- Homepage:
- Size: 110 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Security JWT Authentication
## Gradle based spring boot application which provide below APIs of the users using test driven development.
## APIs of the Application
- Signup
- Login
- Get all users
- Get user by username
## APIs
### Signup - `/auth/signup`
* `NOTE` - this API can be accessed by everyone.
* Request
```
curl --location --request POST 'http://localhost:8080/auth/signup' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "test_username",
"password": "test_password",
"role": "ROLE_test",
"firstname": "test_firstname",
"lastname": "test_lastname"
}'
```
* Response
```
{
"status": "success",
"code": "CREATED",
"message": "user has created successfully",
"data": {
"token": "JWT_TOKEN"
}
}
```
### Login - `/auth/login`
* Request
```
curl --location --request POST 'http://localhost:8080/auth/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "test_username",
"password": "test_password"
}'
```
* Response
```
{
"status": "success",
"code": "OK",
"message": "user has logged in successfully",
"data": {
"token": "JWT_TOKEN"
}
}
```
### Get all users - `/users`
* `NOTE` - this API can be accessed by authenticated users who are having admin role.
* Request
```
curl --location --request GET 'http://localhost:8080/users' \
--header 'Authorization: Bearer JWT_TOKEN' \
```
* Response
```
{
"status": "success",
"code": "OK",
"message": "fetched users details successfully!!",
"data": {
"users": [
{
"username": "test_username",
"password": "test_password",
"firstname": "test_firstname",
"lastname": "test_lastname",
"role": "ROLE_test"
}
]
}
}
```
### Get User by username - `/users/{username}`
* `NOTE` - this API can be accessed by authenticated users who are having admin and user roles.
* Request
```
curl --location --request GET 'http://localhost:8080/users/test_username' \
--header 'Authorization: Bearer JWT_TOKEN' \
```
* Response
```
{
"status": "success",
"code": "OK",
"message": "fetched user details successfully!!",
"data": {
"user": {
"username": "test_username",
"password": "test_password",
"firstname": "test_firstname",
"lastname": "test_lastname",
"role": "ROLE_test"
}
}
}
```