Giter VIP home page Giter VIP logo

authentication's Introduction

Overview

An Authentication API that currently runs with FastAPI, verifies a provided UserCredential with a MySQL DB, and returns an appropriate response.

To do next:

  • Include a monitoring dashboard for responses from API
  • To handle virtual environment, consider:
    • containerization (Docker),
    • App deployment (Heroku),
    • Container orchestration (Kubernetes),
    • venv activation scripts
    • package managers (pipenv / poetry)

Relevant commands

To activate virtual environment: source myenv/bin/activate

To download all dependencies: pip3 install -r requirements.txt

To run FASTAPI: uvicorn main:app --reload

To update list of dependencies: pip3 freeze > requirements.txt

Backend Components:

  1. API: FastAPI Python
  2. DB: FreeDB (1 DB, 50MB, Limited Queries1)
  3. Monitoring: Grafana (TODO)

What a UserCredential is:

  • A username, where first 2 characters indicate the user's country (e.g. SGuser1, USuser2) (min. length = 3)
  • A password (min. length = 1)

API Logic:

  1. First check if username and password provided meet minimum length requirements
  2. Parse the country code out of the username and check if the country code is valid
  3. Verify credentials against DB/file: check by username match, followed by hashed password match
  4. Return an appropriate message or error, depending on where in the authentication the input fails

How to test the API:

  1. First run uvicorn main:app --reload
  2. Go to localhost:8000/docs to send POST requests

Assumptions:

  1. Usernames must be at least 3 characters long (2 for the country code, 1 for the name)
  2. Passwords are at least 1 character long (made with extensibility in mind)
  3. Passwords can include special characters like ! and numbers
  4. pycountry's library contains a reliable source of alpha-2 country codes, which is used for authentication
  5. User may input capital letters for country code, API is modified to still work
  6. Country code in database is always lowercase

Equivalence classes of test cases

Tested manually.

  1. Valid username and password
  2. Non-matched username, valid password
  3. Valid username, invalid password
  4. Invalid country code
  5. Username too short, password too short

Footnotes

  1. MAX QUERIES PER HOUR 800, MAX UPDATES PER HOUR 800, MAX_CONNECTIONS_PER_HOUR 800, MAX Connections 800 โ†ฉ

authentication's People

Contributors

hermit46 avatar

Stargazers

 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.