lexxai / goit_python_web_fastapi_lect_01

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AUTH

HTTPBearer, HTTPAuthorizationCredentials

  • signup: auth-03

  • get_token/login by json: auth-02

  • access with token: auth-01

OAuth2

  • get_token/login by oauth2 form: auth-02

  • get_token/login by oauth2 form: auth-02

  • get_token/login by oauth2 form: auth-02

  • access with token: auth-02

OAuth2 + refresh

  • get_token/login by oauth2 form with refresh: auth-02

  • token refresh saved to Database: auth-02

  • decoded refresh token: auth-02

  • token refresh by refresh_token: auth-02

  • decoded new refresh token: auth-02

REAUTH BY REFRESH_TOKEN in COOKIES

Define cookie for refresh_token auth-cookies

Auth using a refresh_token (cookie) sicne access_token has expired and get a new access_token, and the client side should save and use its new new_access_token as the next access_token auth show new token

Next auth with use new access_token as access_token auth with new token

Auth using a refresh_token (cookie) and check on saved DB, sicne access_token has expired and get a new access_token, and the client side should save and use its new new_access_token as the next access_token auth show new token

USE REFRESH_TOKEN in COOKIES + REFRESH_TOKEN IN DB

Set changed in DB auth show new token

Now rigth refresh_token by sign not aceeped, since not same as DB auth show new token

After wrong refresh_token used, refresh_token in DB cleared auth show new token

GRAVATAR LINK

auth GRAVATAR

JavaSript Client

Login

login

Auth token local storage

 Auth token local storage

List cats and owners

List cats and owners

Owner create

Owner create

Client Js FastAPI Static

Index

index

Login

index

List

index

Docs

index

Client Js FETCH ERROR AND REFRESH TOKEN

First success REFRESH TOKEN and relaod data of cats

index

Limit of bad try REFRESH TOKEN by calling himself and redirect to login page if fail.

index

SEND EMAIL

API

index

WEBMAIL

index

Sign up

index

WEBMAIL Confirmation email

index

Click confirm link

index

User on database changed filed confirmed

index

User login deny before confirm by link

index

User login allowed after confirm by link

index

Redis cache SQL

Save to redis

save redis

Get from redis

get redis

DOCKER

.env

POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=XXXXXXX
POSTGRES_HOST=pg,localhost
POSTGRES_PORT=5432
POSTGRES_DB=fastapi
TOKEN_SECRET_KEY="some secret"
AUTH_LIB=OAuth2

RUN

docker-compose up -d code

About


Languages

Language:Python 82.1%Language:HTML 8.1%Language:JavaScript 5.6%Language:CSS 1.5%Language:Dockerfile 1.2%Language:Batchfile 0.8%Language:Mako 0.7%Language:Shell 0.2%