Giter Site home page Giter Site logo

java-shoppingcart's Introduction

Project Shopping Cart

A Student that completes this project shows they can:

  • understand the flow and implementation of Spring Security and OAuth2 to provide authentication for a project
  • read user information from the access token
  • understand the issues related to CORS and implement solutions to those issues
  • understand how to implement a new user and logout endpoints
  • use Postman to manually test Web APIs using Authentication

Introduction

A shopping cart is a very common application so let's look at one. This Java Spring REST API application will provide endpoints for clients to perform the various CRUD operations on data sets contained in the application's data. Access to these endpoints will be secured using OAuth2 Authentication.

Database layout

You are creating a Java Spring REST API server which stores data in an H2 database. The final table layout should be

Shopping Cart Database Layout

All tables contain the following auditing fields

  • createdby - user name who created the row. Should default to SYSTEM
  • createddate - date field when the row was created
  • lastmodifiedby - user name who last changed data in the row. Should default to SYSTEM
  • lastmodifieddate - date field when the data in the row was last changed

Table Relationships include

  • Users is the driving table and can be thought of as "Customers".
  • Users have a Many to Many relationship with Products. One user can have many products in their "shopping cart" while a product may appear in many different users "shopping cart".
  • A shopping cart is the collection of relationships between a user and product and is modeled using the join table CartItems which contains the quantity of the product being ordered.
  • Users have a Many to Many relationship with Roles. A user can have many roles while many users can have the same role.

You are to start with the initial application provided. To find out the endpoints available to you in the initial application, you will need to use the Swagger document. Remember the Swagger documentation can be access at http://localhost:2019/swagger-ui.html once the application is running.

Instructions

  • Please fork and clone this repository.
  • This repository does have a starter project, so you must start with that application inside of the cloned repository folder. Regularly commit and push your code as appropriate.
  • A data.sql file has been provided with seed data. You can use this class directly or modify it to fit your models. However, the data found in the file is the seed data to use!
  • Note that all of the users' passwords are LambdaLlama.
  • Note that For the final project, passwords in the data.sql file will need to be converted to BCrypt! To convert Bcrypt, you can use the website https://bcrypt-generator.com/. Once you have the BCrypt string, you will replace LambdaLlama with that BCrypt string.

MVP

  • Add OAuth2 Security to the application
    • Add the necessary dependencies
    • Update User model as appropriate
    • Add findByName to the User Service with associated repository entry
    • Add the necessary helper functions
    • Add the SecurityUserService service
    • Add and update the necessary configuration files
  • The initial endpoints are affected by security as follows
    • Only admins can access routes /roles/**
    • Only admins can access routes /products/**
    • Only admins can access routes
      • POST /users/user
      • DELETE /users/user/{id}
      • PUT /users/user/{id}
      • GET /users/user/name/{userName}
      • GET /users/user/name/like/{userName}
      • GET /users/user
      • PATCH /users/user/{id}
      • GET /users/user/{userId}
    • For the routes /carts/**
      • All authenticated users can access /carts/***
      • Remove the user/{userid} path variable from all the routes
      • Use the authenticated as the user to work with

Stretch Goals

  • Add new endpoints
  • Address CORS
  • For the following routes, admins can access them and a user can access only their own data
    • PATCH /users/user/{id}
    • GET /users/user/{userId}

java-shoppingcart's People

Contributors

jrmmba8314 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.