auth_helper: basic method to gen a permenant token

Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
HeshamTB 2022-04-17 02:20:14 +03:00
parent a329ad3b10
commit 4617e5a7a2
Signed by: Hesham
GPG Key ID: 74876157D199B09E
3 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,5 @@
- [ ] Redesign database
- [ ] Define mergancy triggers (manual and automatic)
- [ ] Define emrgancy triggers (manual and automatic)
- [ ] Expose temporary control in case of emergancy
- Triggers
- Acccess

View File

@ -41,3 +41,8 @@ def valid_api_key(key = Security(api_key_header)):
if not __API_KEY == key:
raise HTTPException(401, detail="invalid key")
return
def create_iot_dev_token(data: dict):
to_encode = data.copy()
encoded_jwt = jwt.encode(to_encode, JWT_SECRET, algorithm=JWT_ALGO)
return encoded_jwt

View File

@ -1,5 +1,5 @@
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm, OAuth2AuthorizationCodeBearer
from fastapi.security.api_key import APIKey
from sqlalchemy.orm import Session