https://github.com/shaikrasheed99/springboot-security-basics
Springboot Security Basics application
https://github.com/shaikrasheed99/springboot-security-basics
spring-security springboot springboot-security springsecurity
Last synced: 7 months ago
JSON representation
Springboot Security Basics application
- Host: GitHub
- URL: https://github.com/shaikrasheed99/springboot-security-basics
- Owner: shaikrasheed99
- License: mit
- Created: 2023-10-14T17:36:06.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-13T04:10:45.000Z (almost 2 years ago)
- Last Synced: 2025-01-13T19:38:57.268Z (9 months ago)
- Topics: spring-security, springboot, springboot-security, springsecurity
- Language: Java
- Homepage:
- Size: 87.9 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spring Security Basics application
## Gradle based spring boot application which provide below APIs of the users using test driven development.
## APIs of the Application
- Signup
- Authenticated
- Get all users
- Get user by username## APIs
### Signup - `/signup`
* `NOTE` - this API can be accessed by everyone.
* Request
```
curl --location --request POST 'http://localhost:8080/signup' \
--header 'Content-Type: application/json' \
--data '{
"username": "test_username",
"password": "test_password",
"role": "ROLE_user",
"firstname": "test_firstname",
"lastname": "test_lastname"
}'
```* Response
```
{
"code": "CREATED",
"status": "success",
"data": {
"message": "user successfully signed up"
}
}
```### Authenticated - `/authenticated`
* `NOTE` - this API can be accessed by only authenticated users
* Request
```
curl --location --request GET 'http://localhost:8080/authenticated' \
--header 'Authorization: Basic Y2FwdGFpbjpwYXNzd29yZA=='
```* Response
```
{
"code": "OK",
"status": "success",
"data": {
"message": "This API is accessed by only authenticated users"
}
}
```### 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: Basic aXJvbm1hbjpwYXNzd29yZA=='
```* Response
```
{
"code": "OK",
"status": "success",
"data": [
{
"username": "test_username",
"role": "ROLE_user",
"firstname": "test_firstname",
"lastname": "test_lastname"
}
]
}
```### 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: Basic dGhvcjpwYXNzd29yZA=='
```* Response
```
{
"code": "OK",
"status": "success",
"data": {
"username": "test_username",
"role": "ROLE_user",
"firstname": "test_firstname",
"lastname": "test_lastname"
}
}
```