diff --git a/README.md b/README.md index a65496b..d5884b5 100755 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ -# Authentication gate with Flask & JWT -This repository represents the source code template for micro webserver that provides authentication gate for your protected resources. +# JWT Authentication & DB templates in Flask +This repository contains source code template(s) for running micro webserver with both public and protected routes. -It is written in `Python` using `Flask` framework and relies on `JWT` authentication mechanism. +Authentication mechanism is `JWT` and webserver framework is `Flask`. + +_Please note:_ Some of the provided strategies are to basic/simple for **serious**, production level webserver. Use this template as starting point for more complex projects and requirements. +_**ENJOY !!**_ + ### JWT based `JSON Web Tokens` - or [JWT](https://jwt.io/) in short - is the foundation authentication principle used in this template. Be sure **not to forget** to encode/decode token generation at your own strategy. Follow code comments for exact place where you could modify or customise this behaviour. @@ -15,30 +19,41 @@ In basic form, the code handles all authentication tokens **in memory**, making For more convenient mechanism, store your tokens in some form of persistent storage, or reuse them in different way. Data handling services supported so far: -1. SharedStorage (trivial implementation of in-memory storage) -2. MySQL wrapper -3. MongoDB wrapper +1. `SharedStorage` (trivial implementation of in-memory storage) +2. `MySQL` wrapper +3. `MongoDB` wrapper ### Modularised Template is designed to support modular structure. Following structure is used: -``` - - flask-auth-template - | - | - / services (# contain various services) - / modules (# contain various additional modules) - / models (# contain data models used in this template) +```mermaid +flowchart TB +main-module + subgraph models + subgraph services + mongoDB + mySql + SharedStorage + end + subgraph modules + auth + protected + end + user + end +main-module-->models +user-.->services +user-.->modules ``` *NOTE:* -Main application modules are stored in `modules` folder. If you need more modules, you can place them inside - as long as they are connected in the main module. Customize your Flask bluperints to support modularized approach you need. +Main application modules are stored in `modules` folder. If you need more modules, you can place them inside - as long as they are connected to `main-module`. Customize your Flask bluperints further to support modularized approach you need. ### Different authentication strategies Presented here is **basic** HTTP AUTHENTICATION through Authentication field. Note there are **way secure** authentication mechanisms, such as `OAuth`. #### CORS setup -For the sake of simplicity, CORS has been enabled completely. Server will accept all origins no matter where the request comes from. Check and/or modify `@app.after_request` directive to further customise desired behaviour (lines [20-24](https://github.com/vexy/flask-auth-template/blob/master/main-module.py#L20-L24) in `main-module.py`). +For the sake of simplicity, CORS has been enabled completely. Server will accept all origins no matter where the request comes from. Check and/or modify `@app.after_request` directive to further customise desired behaviour (lines [25-28](https://github.com/vexy/flask-auth-template/blob/master/main-module.py#L25-L28) in `main-module.py`). ### Installation Before you begin: @@ -74,10 +89,11 @@ There might be a struggle with starting this project, due to known collision of To solve this, you might have to "fix" (play around with) your `PYTHONPATH`. Check out this [article](https://bic-berkeley.github.io/psych-214-fall-2016/using_pythonpath.html) for more information. ---- - #### Word of wisdom -If you ever get stuck remember that `sudo` is your friend. If it doesn't help, start thinking how one cold 🍺 can magically improve your understanding of the 🌎. +> If you ever get stuck remember that `sudo` is your friend. If it doesn't help, start thinking how one cold 🍺 can magically improve your understanding of the 🌎. +---- +MIT License Copyright © 2020 Veljko Tekelerović -MIT License +PGP: `6302D860 B74CBD34 6482DBA2 518766D0 8213DBC0` \ No newline at end of file