Best Flask open-source libraries and packages

SSO Flask

SSO API written in python using flask framework
Updated 1 year ago

SSO Flask

A python application written using Flask to reduce creating passwords on several websites for logging in

SSO-Flask-Arch

How websites can use it

  • Ask user to Sign Up/Login using the hosted API
  • Generate token for website domain
  • Use generated token to authenticate user for accessing website
  • Release generated token for the domain

Usage

API endpoints

Endpoint METHOD Params Desc
/api/user/generate POST email, name returns msg and authToken
/api/user/getId POST authToken returns userId
/api/user/details POST authToken returns user details (full name, tokens generated domains, and masked email id)
/api/user/token/generate POST authToken, id, domain returns new token for requested website, use this endpoint to reset web token
/api/user/token/status POST authToken, id, domain returns if token is still valid or not (should be used by website's backend server to get token status )
/api/user/token/release POST authToken, id, domain revokes token for assigned domain

Users table in DynamoDB

id name emailId auth_tokens
0e2xx8fc-5xex-47x1-99xx-0869adxxxxxx your-full-name your-email@domain.co {"domain-01":"token-01","domain-02":"token-02","domain-03":"token-03"}

Installation and Usage

For Debian based OSes

  • Install curl

    sudo apt install curl -y
  • Use install.sh script from repo

    bash -c "$(curl -fsSL https://raw.githubusercontent.com/dmdhrumilmistry/SSO-Flask/main/install.sh)"

Manual Method

  • Clone/Download repo

    git clone --depth=1 https://github.com/dmdhrumilmistry/SSO-Flask.git
  • Change directory

    cd SSO-Flask
  • Install requirements

    python -m pip install -r requirements.txt

    ubuntu/debian users might need to use python3 instead of python

  • Create a new .env file with AWS creds in SSO-Flask directory

    AWS_ACCESS_KEY_ID='aws-access-key-id'
    AWS_SECRET_ACCESS_KEY='aws-secret-access-key'
    AWS_REGION_NAME='your-aws-zone'

    Programmatic access is required to perform this action

  • Start waitress server

    waitress-serve --listen=*:5000 app:app

    Allow HTTP traffic on port 5000 for EC2 instance

Tags sso