Skip to main content


Showing posts from 2017

Microservices 101, Docker & spring boot sample [Windows 10, home]

This is a very simplistic article :) if you are looking for a deep dive in microservices, see my state-of-the-art microservices full archeticture here:   What are micro services? It's an architectural model for web services that basically requires each service** to be completely independent and loosely coupled from other consumer services, or services that it depends on. and it's not a new idea but it's catching pace in today large scale web applications. ** (by service we mean a component that controls and implements the business logic in a self contained manner, like orders service, products catalog service, accounts management service, all of these have their domain and can be clearly separated)   Why micro services emerged ? 1- Easy to scale services: if you have a single application and all the services share the same code base and war (package) then if you receive high demand on one

Spring security OAuth2 + spring boot, Part 2

In this 2nd part I made a more complex example to be more practical in real life, and created a web app that is gets its users from db and stores the clients, and tokens in db instead of memory so it's more scalable. features: 1- users & roles in database 2- oauth related info stored in db (tokens, clients, approvals, etc..) 3- two APIs : a- cats apis, b- dogs api; each one of these can be accessed only if the access token has a proper scope (cats scope and dogs scope) the app uses h2 in memory database so that it be self contained and no external setup is required and here is the source code : show case: 1- get access token to with scope cats: a- get the auth code : go to : localhost:8080/oauth/authorize?response_type=code&client_id=cats-client&redirect_uri=http://localhostcats/redirect 2- login with a user 3- approve the scopes : 4- get the authorization code

Spring Security OAuth2 + Spring Boot, minimalist working, extendable configuration - Part 1

Hi been a while again.. today i'm back to write on how to write the simplest possible spring boot app protected with spring security oauth2, but i'll also make the project as a library jar that can be reused for any new projects to kick off faster.  and it will be a simple ready to override functions that will let you focus on configuring only things that you need to worry about without having to worry about annotations or other spring security stuff. Overview Spring security oauth 2 has three main components : a- Authorization server: to handle tokens/authroization codes and user approve/deny b- Resource server: protects the actual apis that we want to be protected by oauth2 c- spring web security configs to manage users authentication and as simple as it sounds to get these three in one simple hello world example required hours and hours of searching and debugging dont ask me why.. Pre Requests : 1- you know spring security & spring web security conce