Giter Site home page Giter Site logo

authorization_service_example's Introduction

Authorization Service

Background:

A client would like to access the Resource API behind an Authroization Server, therefore, the client must first authenticate with the Authroization Server in order to retrieve information from the Resource API .

Description

This project is a Python prototype simulating the communication between client, authorization service, resource API. The authorization service is used to guard specific API resource behind. This project has three servers:

to simulate the server side application oauth2 authorization flow. More details regard to Oauth2 authorization flow can be found here

Flow to retrieve resource in api_server

authorization flow chart note: username and password are both "admin" for authorization

Prepare Environment

Ensure python3.9 or above is available in your environment

# create virtual environment
python -m venv venv

# activate the environment
source venv/bin/activate

# install required dependencies
pip install -r requirements.txt

Launch Servers in Dev Environment

Follow the commands below to launch the servers in separate terminals

  • launch client

    cd {project_root}/client_server
    uvicorn client_server:app --reload --port 8000
    
  • launch authentication/authorization server

    cd {project_root}/auth_server
    uvicorn auth_server:app --reload --port 8001
    
  • launch api server

    cd {project_root}/api_server
    uvicorn api_server:app --reload --port 8002
    

Work to complete this prototype

Since this is a prototype, there are several points below need to be completed if this authorization service is put into real use. Currently neither authorization code or access code has expiration time.

  • Include expiration time in encoding to produce authorization code, and disable authorization code when it expires.
  • Apply safer encryption to generate authorization code
  • Implement access code management by specific scheme. This scheme should specify how to
    • generate the access code
    • share the access code between auth_server and api_server
    • disable it when it expire
  • (Optional) Create mapping among user, client and api resource

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.