View on GitHub

eCommerce_app

E-commerce App

E-Commerce Application

This is a simple e-commerce application with proper authentication and authorization controls so users can only access their data, and that data can only be accessed in a secure way.

Packages and Classes

This project has 5 packages, as follows:

Example:

To create a new app user we send a POST request to: http://localhost:8080/api/user/create with an example body like

{
    "username": "test"
    "password": "somepassword"
    "confirmpassword": "somepassword"
}

and this would return

{
    "id" 1,
    "username": "test"
}

We can use Spring’s default /login endpoint to login like:

POST /login 
{
    "username": "test",
    "password": "somepassword"
}

and it would return a 200 OK with an Authorization header which looks like “Bearer " this "Bearer " is a JWT and must be sent as a Authorization header for all other requests. If it's not present, endpoints will return 401 Unauthorized. If it's present and valid, the endpoints will function as normal.

Run the code

To run this service you execute:

$ mvn clean package
$ java -jar target/auth-course-0.0.1-SNAPSHOT.jar

It can also be imported in your IDE as a Maven project.