Giter VIP home page Giter VIP logo

light-oauth2's Introduction

A fast, light weight and cloud native OAuth 2.0 Server based on microservices architecture built on top of light-4j and light-rest-4j frameworks.

Stack Overflow | Google Group | Gitter Chat | Subreddit | Youtube Channel | Documentation | Contribution Guide |

Build Status

Light platform follows security first design and we have provided an OAuth 2.0 provider light-oauth2 which is based on light-4j and light-rest-4j frameworks with 7 microservices. Some of the services implement the OAuth 2.0 specifications and others implement some extensions to make OAuth more suitable to protect service to service communication, other styles of services like GraphQL, RPC and Event Driven, Key management and distribution, service registration, token scope calculation and token exchange.

Why this OAuth 2.0 Authorization Server

Fast and small memory footprint to lower production cost.

It can support 60000 user login and get authorization code redirect and can generate 700 access tokens per second on my laptop.

It has 7 microservices connected with in-memory data grid and each service can be scaled individually.

More secure than other implementations

OAuth 2.0 is just a specification and a lot of details are in the individual implementation. Our implementation has a lot of extensions and enhancements for additional security and prevent users making mistakes. For example, we have added an additional client type called "trusted" and only this type of client can issue resource owner password credentials grant type.

More deployment options

You can deploy all services or just deploy the services for your use cases. You can deploy token and code service to DMZ and all others internal for maximum security. You can have several token services or deploy token service as sidecar pattern in each node. You can start more instance of key service on the day that your public key certificate for signature verification is changed and shutdown all of the but one the next day. You can take the full advantages of microservices deployment.

Seamlessly integration with Light-Java framework

  • Built on top of light-4j and light-rest-4j
  • Light-4j Client and Security modules manages most of the communications with OAuth2
  • Support service on-boarding from light-portal
  • Support client on-boarding from light-portal
  • Support user management from light-portal
  • Open sourced OpenAPI specifications for all microserivces

Easy to integrate with your APIs or services

The OAuth2 services can be started in a docker-compose for your local development and can be managed by Kubernetes on official test and production environment. It exposes RESTful APIs and can be access from all languages and applications.

Support multiple databases and can be extended and customized easily

Out of the box, it supports Mysql, Postgres and Oracle XE and H2 for unit tests. Other databases can be easily added with configuration change in service.yml.

Public key certificate distribution

With distributed security verification, JWT signature public key certificates must but distributed to all resource servers. The traditional push approach is not working with microservices architecture and pull approach is adopted. There is a key service with endpoint to retrieve public key certificate from microservices during runtime based on the key_id from JWT header.

Two tokens to support microservices architecture

Each service in a microservices application needs a subject token which identifies the original caller (the person who logged in the original client) and an access token which identifies the immediate caller (might be another microservices). Both tokens will be verified with scopes to the API endpoint level. Additional claims in these tokens will be used for fine-grained authorization which happens within the business context.

Token exchange for high security

Even with two tokens, we can only verify who is the original calller and which client is the immediate caller. For some highly protected service like payment or fund transfer, we need to ensure that the call is routed through some known services. light-oauth2 token service support token exchange and chaining so that a service can verify the entire call tree to authorize if the call is authorized or not.

Service registration for scope calculation

light-oauth2 has a service registration to allow all service to be registered with service id and all endpoints as well as scopes for the endpoint. During client registration, you can link a client to services/endpoints and the scope of the client can be calculated and updated in client table. This avoids developers to pass in scopes when getting access token as there might be hundreds of them for a client that accesses dozens of microservices.

All activities are audited

A database audit handler has been wired into all light-oauth2 services to log each activity across services with sensitive info masked. In the future we will put these logs into AI stream processing to identify abnormal behaviors just like normal service log processing.

OAuth2 server, portal and light-4j to form ecosystem

light-java to build API

light-oauth2 to control API access

light-portal to manage clients and APIs

Introduction

This introduction document contains all the basic concept of OAuth 2.0 specification and how it work in general.

Getting started

The easiest way to start using light-oauth2 in your development environment is through docker-compose in light-docker repository. Please refer to getting started for more information.

Architecture

There are some key decision points that are documented in architecture section.

Documentation

The detailed service document help users to understand how each individual service works and the specification for each services. It also contains information on which scenarios will trigger what kind of errors.

Tutorial

There are tutorials for each service that shows how to use the most common use cases with examples.

Reference

There are vast amount of information about OAuth 2.0 specifications and implementations. Here are some important references that can help you to understand OAuth 2.0 Authorization.

light-oauth2's People

Contributors

atmoshaman avatar dependabot[bot] avatar dineshalapati avatar dz-1 avatar gavinchenyan avatar miklish avatar smerschjohann avatar stevehu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

light-oauth2's Issues

Implement custom grant type client_authenticated_user

For this grant type, the client application(normally will be web server) is responsible for authenticating user (single sign on most of the case) and send user info to the token endpoint to get access token. The passed in user info must contain the following fields.

userId
userType

Any other fields will be added to the JWT claim automatically.

This is the requirement from one of our clients as they have single sign on already on their web server and need to get a token to access APIs.

Upgrade docker-compose files and db configurations to 1.5.4

In release 1.5.4, we need separate service.yml config file for each oauth2 services. The change has been done in light-docker and we need to do the same for the local build here in light-oauth2. The light-docker compose file is for developers to start OAuth2 providers in his/her local while working on the API projects. The compose file here is for developers who are working on light-oauth2. So the compose is using local build instead of docker hub.

Receive 403 after successfully registering a new service

Hi Steve,

I am using light-oauth2 to register a new service. When I register my new service I get back a 403 however I see that the request was successful when I do a GET.

Here is my request:

curl --request POST \
  --url http://localhost:6883/oauth2/service \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{\n"serviceId":"TEST0005",\n"serviceType":"api",\n"serviceName":"Retail Account",\n"serviceDesc":"Microservices for Test Account",\n"scope":"test.r",\n"ownerId":"admin"\n}'

To reproduce please use the version from master and docker-compose-mysql.yml

Thanks,
Gonzalo

CORS issue when calling from a SPA

Hi Steve,

I have an SPA that calls light-oauth2.

After trying the latest version of light-oauth2 that supports CORS, I am still getting this error:

XMLHttpRequest cannot load http://localhost:6883/oauth2/service?page=1. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

Could it be because we are specifying the port number?

Thanks,
Gonzalo

service registration and retrieval createDt is null in the result.

The createDt might not even be populated in post request or it is not retrieved in get request. Need some investigation.

docker-compose -f docker-compose-oracle.yml up
curl --request POST --url http://localhost:6883/oauth2/service --header 'cache-control: no-cache' --header 'content-type: application/json' --data '{"serviceId":"MRKT0002","serviceType":"api","serviceName":"Retail Account","serviceDesc":"Microservices for Marketplace Account","scope":"mrk.r","ownerId":"admin"}'

curl http://localhost:6883/oauth2/service?page=1

Result

[{"serviceId":"AACT0001","serviceType":"ms","serviceName":"Account Service","serviceDesc":"A microservice that serves account information","ownerId":"admin","scope":"a.r b.r","createDt":"2017-02-20","updateDt":null},{"serviceId":"MRKT0002","serviceType":"api","serviceName":"Retail Account","serviceDesc":"Microservices for Marketplace Account","ownerId":"admin","scope":"mrk.r","createDt":null,"updateDt":null}]

Support state in authorization code grant type

This is RECOMMENDED in the specification. An opaque value used by the client to maintain state between the request and callback. The authorization server includes this value when redirecting the user-agent back to the client. The parameter SHOULD be used for preventing cross-site request forgery.

remove default config for production package

This is requested by a customer and it makes sense. We really don't want anyone to deploy the default tls certificates and jwt signature public key certificates on production.

clientSecret hash is leaked on GET request

Currently the hash of the clientsecret is leaked if details to a clientId are requested.

It would be better to nullify this value in Oauth2ClientClientIdGetHandler.java before returning it.

Receive Unexpected runtime exception when registering a service.

Hi Steve,

I receive an Unexpected runtime exception when I am running light-oauth2 docker-compose-oracle.yml. It does not happen with the SQL version. I have only been able to reproduce it with oracle.

Here is my POST request:

curl --request POST \
  --url http://localhost:6883/oauth2/service \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{\n"serviceId":"MRKT0002",\n"serviceType":"api",\n"serviceName":"Retail Account",\n"serviceDesc":"Microservices for Marketplace Account",\n"scope":"mrk.r",\n"ownerId":"admin"\n}'

To reproduce please use the version from master and docker-compose-oracle.yml

Thanks,
Gonzalo

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.