Code Monkey home page Code Monkey logo

carlease-customer-service's Introduction

Customer Service for Carlease assigment

Functionality

RESTFull webservice facilitating CRUD operations on a Customer datastore Not using Spring REST repositories for this service (even though that would speed things up tremendously) Endpoints require a valid JWT issued by an API-gateway sharing the same secret

  • list customers
  • create customer
  • fetch customer by id
  • update customers attribute
  • delete specific customer
  • fetch customers by name keyword
  • authentication
  • containerize

Phasing depends on how much time can be made free

URL mapping

  • Phase 1: Basic URL mapping docs
  • Phase 2: Swagger docs / REST Docs
api prefix and version should be handled by an api gateway
- [x] GET:    {domain}/customers          - returns al customers
- [x] GET:    {domain}/customers/{id}     - returns specific customer
- [x] POST    {domain}/customers          - create new customer
- [x] DELETE: {domain}/customers/{id}     - delete specific customer
- [x] PUT:    {domain}/customers/{id}     - update specific customer

Sample POST/PUT Body

{
  "firstName": "fname",
  "lastName": "lname",
  "lastNamePrefix": null,
  "phoneNumber": "0101234567",
  "email": "[email protected]",
  "street": "teststraat",
  "postalCode": "1234AB",
  "houseNumber": 123,
  "addition": null,
  "city": "teststad"
}

Authentication

  • Phase 1: using JWT with using symmetric keys
  • Phase 2: using JWT adding refresh token
  • Phase 3: using JWT using asymmetric keys
  • Phase 4: JWT facilitated by Keycloak
docker run -p 9090:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:13.0.1

Phase 1: JWT with using symmetric keys

This service shall not support login and generating JWT's that is delegated to another service. This service only needs to be able to validate the token even though a first validation is performed at the system entry point. All endpoints need authentication, so a global filter is used in front of the controllers to check for a valid JWT. User details are not required by this service and can be made available in claims. Spring Security will therefore not be used by this service. The signing secret is shared between services. From a security viewpoint not the most secure if a secret is compromised.

  • Adding filter (OncePerRequest)
  • Unit Test validation of JWT
  • Integration Test application of filter
  • Modify already present tests with a mock filter

Implementation

JWT is evaluated in a OncePerRequest filter on signature integrity and on expiration using the Nimbus JOSE library.

Run application

This service runs on port 9092

In development use dev profile:

mvn spring-boot:run -Dspring-boot.run.profiles=dev

When not using an authentication service to create a valid token got to jwt.io set the expiration "exp" claim to later then current UTC and use a secret in the dev profile:

JWT payload example

{
  "sub": "1234567890",
  "name": "Jaap Test",
  "exp": 1624003711
}
// current development secret
secret=imasecretimasecretimasecretimasecret

import

docs

carlease-customer-service's People

Contributors

remideboerhva avatar

Watchers

 avatar

carlease-customer-service's Issues

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.