Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/afa-farkhod/springboot-jwt-authentication-authorization
JWT authentication and authorization implementation in Spring Boot 3.0 application
https://github.com/afa-farkhod/springboot-jwt-authentication-authorization
authentication authorization java jwt jwt-authentication postman spring-boot spring-security
Last synced: about 2 months ago
JSON representation
JWT authentication and authorization implementation in Spring Boot 3.0 application
- Host: GitHub
- URL: https://github.com/afa-farkhod/springboot-jwt-authentication-authorization
- Owner: afa-farkhod
- License: apache-2.0
- Created: 2023-07-06T06:04:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-03T06:26:35.000Z (over 1 year ago)
- Last Synced: 2024-04-24T11:08:04.062Z (9 months ago)
- Topics: authentication, authorization, java, jwt, jwt-authentication, postman, spring-boot, spring-security
- Language: Java
- Homepage:
- Size: 177 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SpringBoot-JWT-Authentication-Authorization
JWT authentication and authorization implementation in Spring Boot 3.0 application## [Implementation]()
- The implementation is about the JWT authentication and authorization in Spring Boot 3.0 application using Spring Security 6 and MySQL database to store user credentials. To secure the application and protect endpoints JSON Web Tokens were used. In the beginning we set the MySQL database and create user table to store user's credentials. Then we configure Spring Security to use JWT and define security rules for application. In the end, we test the application by building simple API and using Postman to send authenticated requests.
## Run the Demonstration
- We start the Spring application:
- We can see that table was created:
- Now we register new user to our Database by sending post request with `Postman` client:
- Then we can see that our new user is successfully registered to Database and in fact as we can see password is encoded so that no one except the owner can know the real password:
![image](https://github.com/af4092/SpringBoot-JWT-Authentication-Authorization/assets/24220136/5097d213-a9c7-4762-a8f4-45eb4a8dda06)
- And on Postman Client side we `Authorization JWT token` as the proof of successful registration to Database:
- And now, after registering the user to Database, we try to login with the existing email and password, for this we send request through Postman client to server with the email and password information:
- And as the result we get our token back:
## [Troubleshooting](https://stackoverflow.com/questions/39632667/how-do-i-remove-the-process-currently-using-a-port-on-localhost-in-windows)
- Sometimes when we run the Spring application which in default listens to `port:8080` we get the `port in use` error. In this case we open the terminal and check port: 8080 and kill the PID which is listening to port.
![image](https://github.com/af4092/SpringBoot-JWT-Authentication-Authorization/assets/24220136/52596d27-dd2c-4688-995f-043ca6ec7240)