diff --git a/sql_app/TODO b/sql_app/TODO index 1e6bacd..7e1d2cf 100644 --- a/sql_app/TODO +++ b/sql_app/TODO @@ -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 diff --git a/sql_app/auth_helper.py b/sql_app/auth_helper.py index 12aa271..bbc75d2 100644 --- a/sql_app/auth_helper.py +++ b/sql_app/auth_helper.py @@ -40,4 +40,9 @@ def authenticate_user(db: Session, username : str, password : str): def valid_api_key(key = Security(api_key_header)): if not __API_KEY == key: raise HTTPException(401, detail="invalid key") - return + 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 diff --git a/sql_app/main.py b/sql_app/main.py index 9a9434e..16e415d 100644 --- a/sql_app/main.py +++ b/sql_app/main.py @@ -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