This Project is an example of an eCommerce for selling books: where there are two roles:
- ROLE_ADMIN: can manage books (In Back-office).
- ROLE_CLIENT: buy books on the store
-
I did'n create a FrontEnd application yet
-
I made just some tests for some user services
- SpringBoot - Framwork that reduce boilerplate configuration of Spring application and running with the smallest amount of code.
- [JPA] - A specification that defines the management of relational data in a Java application.
- [Hibernate] - ORM and JPA implementation.
- postgresql - free and open-source relational database.
- H2 - A database loaded in memory (I use it for tests).
- [JavaMail] - Java API used to send and receive email via SMTP.
- thymeleaf - A template engine (I used it to generate Order template before sending it by email).
- MapStruct- A code generation library that generates object mappers.
- Swagger2 - An open-source software framework, that helps developers to document and consume REST web services
- [Mockito] - An open source testing framework
- [JUnit] - A unit testing framework for Java
Use maven to run the following command
$ mvn spring-boot:run
Navigate to the url below to browse the Rest Api documentation.
http://localhost:8080/swagger-ui.html
These endpoints they don't need authentication
book-resource:
- /books/active
- /books/details/{id}
- /search/{keyword}
user-resource
- /users/create
- /users/forgetPassword
Also only ROLE_ADMIN can create update delete a Book
Token URL: http://localhost:8080/oauth/token Flow: password username : admin password : admin client : client secret : secret scope : trust
1 . Click on authorize button
2 . copy-paste | insert credentials
3 . quit authorization view after success authentication 4 . access services
- select authorization
- select oauth2 type
- select get new access token
- type credentials
- select request token
URL: http://localhost:9000/oauth/token Method Type : POST Content-Type : application/x-www-form-urlencoded
For example : https://www.blitter.se/utils/basic-authentication-header-generator/
- username => client
- password => secret
Authorization: Basic Y2xpZW50OnN6Y3JldA==
grant_type password
username admin
password admin
scope trust
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsic3RvcmUtcmVzb3VyY2UiXSwidXNlcl9uYW1lIjoiYWRtaW4iLCJzY29wZSI6WyJ0cnVzdCJdLCJleHAiOjE1NzM1Mjc4MjEsImF1dGhvcml0aWVzIjpbIlJPTEVfQURNSU4iXSwianRpIjoiNzk5ZWQzN2QtOWQzNy00NDczLThiZjgtZTBjMzliNTg0YWY4IiwiY2xpZW50X2lkIjoiY2xpZW50In0.w6pYuNpJXGonrhHYUnxtlQLd8JeFqfqFFE_De0lS7SE",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsic3RvcmUtcmVzb3VyY2UiXSwidXNlcl9uYW1lIjoiYWRtaW4iLCJzY29wZSI6WyJ0cnVzdCJdLCJhdGkiOiI3OTllZDM3ZC05ZDM3LTQ0NzMtOGJmOC1lMGMzOWI1ODRhZjgiLCJleHAiOjE1NzYxMTk3NjEsImF1dGhvcml0aWVzIjpbIlJPTEVfQURNSU4iXSwianRpIjoiOTdiNmVkNjAtNjk3MS00MTg5LThhNTktMTI2MGIwYjVkODYxIiwiY2xpZW50X2lkIjoiY2xpZW50In0.mhCj4W7KaI4yEAIBMv-IzoARZhrZQ1iJDL3YOt2zG0A",
"expires_in": 59,
"scope": "trust",
"jti": "799ed37d-9d37-4473-8bf8-e0c39b584af8"
}