Coder Social home page Coder Social logo

mehdi-hafid / bff Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 16 KB

Nidam is a collection of Spring OAuth 2 microservices and a React SPA that takes care of Registration and Authentication of Users using the Security Standard OAuth 2. So You only focus on Business Logic

Home Page: https://nidam.derbyware.com

Java 100.00%
authentication authorization-server backendforfrontend bff java java17 java17-spring-boot jdk17 oauth2 oauth2-resource-server

bff's Introduction

Nidam is a collection of Spring OAuth 2 microservices and a React SPA that takes care of Registration and Authentication of Users using the Security Standard OAuth 2. So You only focus on Business Logic.

visit: https://nidam.derbyware.com

What is Nidam

You want to start coding a new spring application but first registration and authentication are required before you start writing your backend and front code.

Nidam solves this problem using the standard OAuth 2, by providing:

  • Registration backend connected to a MySQL database for credentials storage.
  • Registration React front page to interface with registration API.
  • Registration comes with Google Recaptcha.
  • Spring Authorization Server backend that's responsible for the login process and generating the token.
  • Spring OAuth 2 Resource Server backend, is where your code lives.
  • React front initiates login, logout, and access to secured resource server endpoint, this is where your front code lives.

Now this is actually not enough for an OAuth2 secured application to work. See the front code is not allowed to receive and save the token for subsequent API calls. We need to implement what is called Backend For Frontend (BFF) pattern. This is a Spring OAuth2 Client that receives and saves tokens. It is a bridge between the front and the resource server. Upon successful login, the token is sent to this BFF where it is stored securely. Before the BFF redirects to the front end, it generates a SESSION cookie for the front when redirected. When the front wants to make a call to the resource server, it always goes through the BFF that replaces the cookie with the token associated with it and calls the resource server, which validates the token and returns the result for the front.

The BFF implemented by Nidam is taken from this baeldung article OAuth2 Backend for Frontend With Spring Cloud Gateway by Jérôme Wacongne

So for the BFF, we need two backend microservices:

  • Reverse Proxy: the front, the authorization server, and the BFF live behind the reverse proxy. We need the front and the BFF to have the same origin so the SESSION cookie works. Serving the authorization server behind the reverse proxy is an implementation choice.
  • BFF (backend for frontend): as explained above, this is a bridge between the front and resource server to translate the SESSION cookie to the token.

Requirements:

This book covers Spring Security OAuth2: link

Nidam will not teach you these. This documentation will only explain how it uses them to achieve its goal.

Nidam uses React as the front framework, you can replace this with any SPA framework.

Nidam uses Java 17 version and React 18.

Each microservice is hosted on its own repository.

bff's People

Contributors

mehdi-hafid avatar

Watchers

 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.