From a243149bf112cec2c3d798d8eb266b990c14739c Mon Sep 17 00:00:00 2001 From: Robin COuret Date: Thu, 5 Mar 2026 22:38:21 +0100 Subject: [PATCH] structure auth --- server/__pycache__/config.cpython-311.pyc | Bin 0 -> 1271 bytes server/requirements.txt | 1 + server/{ => src/app}/.env.example | 3 +- .../app/__pycache__/config.cpython-311.pyc | Bin 1075 -> 1507 bytes .../app/__pycache__/database.cpython-311.pyc | Bin 1108 -> 1108 bytes .../src/app/__pycache__/main.cpython-311.pyc | Bin 1528 -> 1528 bytes server/src/app/api/v1/__init__.py | 4 +- .../v1/__pycache__/__init__.cpython-311.pyc | Bin 667 -> 666 bytes .../api/v1/__pycache__/auth.cpython-311.pyc | Bin 0 -> 2640 bytes .../api/v1/__pycache__/users.cpython-311.pyc | Bin 2606 -> 2602 bytes server/src/app/api/v1/{users.py => auth.py} | 6 ++- .../app/auth/__pycache__/auth.cpython-311.pyc | Bin 0 -> 162 bytes .../__pycache__/dependancies.cpython-311.pyc | Bin 0 -> 2503 bytes .../auth/__pycache__/schemas.cpython-311.pyc | Bin 0 -> 814 bytes .../auth/__pycache__/security.cpython-311.pyc | Bin 0 -> 2096 bytes .../auth.py => auth/dependancies.py} | 43 +++--------------- server/src/app/auth/schemas.py | 8 ++++ server/src/app/auth/security.py | 33 ++++++++++++++ server/src/app/config.py | 14 +++--- server/src/app/data/__init__.py | 0 .../data/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 166 bytes server/src/app/main.py | 5 +- server/src/app/models/__init__.py | 0 .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 168 bytes .../models/__pycache__/user.cpython-311.pyc | Bin 732 -> 732 bytes server/src/app/models/user.py | 3 +- .../language_generation.cpython-311.pyc | Bin 1903 -> 1903 bytes 27 files changed, 68 insertions(+), 52 deletions(-) create mode 100644 server/__pycache__/config.cpython-311.pyc rename server/{ => src/app}/.env.example (83%) create mode 100644 server/src/app/api/v1/__pycache__/auth.cpython-311.pyc rename server/src/app/api/v1/{users.py => auth.py} (85%) create mode 100644 server/src/app/auth/__pycache__/auth.cpython-311.pyc create mode 100644 server/src/app/auth/__pycache__/dependancies.cpython-311.pyc create mode 100644 server/src/app/auth/__pycache__/schemas.cpython-311.pyc create mode 100644 server/src/app/auth/__pycache__/security.cpython-311.pyc rename server/src/app/{services/auth.py => auth/dependancies.py} (57%) create mode 100644 server/src/app/auth/schemas.py create mode 100644 server/src/app/auth/security.py create mode 100644 server/src/app/data/__init__.py create mode 100644 server/src/app/data/__pycache__/__init__.cpython-311.pyc create mode 100644 server/src/app/models/__init__.py create mode 100644 server/src/app/models/__pycache__/__init__.cpython-311.pyc diff --git a/server/__pycache__/config.cpython-311.pyc b/server/__pycache__/config.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..976bee0667d5dd87acf2681c225722188f96a6ad GIT binary patch literal 1271 zcmZuw%}*0S6rb%*%TiiCELcP%8V{yMyBaxEVr)uTNQEv)Aw!5&qkU%{2 z-~kg498BQo2}AJU!9Qf1cxdLLi6?J0aN^{fErlSydGnk1-n`lOF|(hO$v6VCejJ*o z0z$vI(x&K{aIAu`hbW?gg{p!k2waX>k*cVP0*atXM8$WAVna9(5juj|A`M57fe%1A zYMYQ2rO^t?#C~&2Mqr6C-7_kN@0<3D2YPhEG%UJw?hgV!Q;t7^u!jt!2^49O1;|Ge z4Qxbdn6QHzBd4z;M(5o)ne>(Hc7leh+1b<$26|I&33f!tuWNQ;L)@$f`K>oOAX z?PTi&)YuI*_WW}qNqeE1J|?wG*dFlKEz>tfWm%@WuP;J*S-Qv)DH>_`J=hVxySP66LxL7piV9nCKXbi8CRxBVYalLs#G0oy8QIfs}V9q z%Gs5bjb)bl$5Abm6^2-BX09|@Qd!c~ZR%8s=ey8Z7OyD9Ic1(qDQ}?3qG50Tz70jQ zn}uRgsZ_}P%#@-M<@Ic74kDM-g?XiN=@Q^^gmiojmWxZ^S3o1s0`at`-GXeSrgs?avRfld^TuuEn`aoWFs)p=3i>57? zb=$E_{gH01t?II8xSNJ6FNI;UYg;VVisoI`gy^>I__}X8wnvC7@%>H?T^#s>bdwx<0hnmoe)v&0&23?f8(fOD zfgkX`0bJx%Lq7-Q+Vt+d0L#F2EH`6l_*sCj?~4J>0oQS^F+39B^nNP9u#VL62>7H1 zY7;xf0QUpeaepIyYj=2.11.0 diff --git a/server/.env.example b/server/src/app/.env.example similarity index 83% rename from server/.env.example rename to server/src/app/.env.example index e3ca509..8107c5e 100644 --- a/server/.env.example +++ b/server/src/app/.env.example @@ -2,5 +2,4 @@ DATABASE_URI="sqlite:///database.db" LANGUAGE_MODEL_API="http://localhost:8080/v1" LANGUAGE_MODEL_NAME="SmolLM3-Q4_K_M.gguf" ORIGIN="http://localhost:5173" -SECRET_KEY="xxxx" #generate secure random secret key: openssl rand -hex 32 -ACCESS_TOKEN_EXPIRE_MINUTES=10080 \ No newline at end of file +SECRET_KEY="xxxx" #generate secure random secret key: openssl rand -hex 32 \ No newline at end of file diff --git a/server/src/app/__pycache__/config.cpython-311.pyc b/server/src/app/__pycache__/config.cpython-311.pyc index b0182d12a3c44cbb5ac2de8dca6a88daef329171..eed296b05fdc5a9760a3015ae13bb0c574e701af 100644 GIT binary patch literal 1507 zcmZux&rcgi6rS~tjSY5O><}D6K}r)UWxJPWL}-gR~t zq@W&r=z&T-&{H_}P*FwnkYoRhS&4(Sr%F9Vy%3QTr@pbV5pieUe*4~=&u?bF8SfvF z$S8vL>%VWc-+c)E!-IbFUpnVSaNZz_sGy^!P!|O5`*dGZtcwEjp)8`}Pl#ewI2I8) zfv4B%*oRbn48ci1h3bClFQH`MJGQI&BR2;NZ*P`~sXe zNJVvlqPnjFGpiyMsP9kl7}kCQPp{Rn>Q@8Q_Y}e|2UGtLXQa#V4>$ojGQ1jG$D+O8gOZ05FT9*7XP#wBGO4WRKuu9K_VyDyj?)6BZZ;Hs$F!Y= z`G@llrM*X9Y&BENRx(+c6xNpIRg!s`+mDx;roLKu^5BPW$Owzqe;y!a=?Vx}PP zPYl(ad-UBCFR-?r%jSw+#8M1uHi_+6aJJrPNnTo)%Vb5ay`KRgygQktCAm~0<+T;L zNaT%|xpi1au2?C{CC~q&^my)DFO*r$Lb>vb!nGSA^v)Tb$H2L|5mcy))CWq57ty{_ zsU_3c(zf?;3Zy6|u@@x7P?{W167wFAw#i0OSr_G)Apm*Z8 z4}!c~w;^xc0VpP;)=eHvaJa>R-+gNYz!O17FG`4F7^b5*nrYaCSRp>n|H9T7hX{u# zfG28(V~z8WSGE!yx)V)tFVF{G-wuGDR|{*SzZ0Jy`Pt0eUul-eyNUd1BHvy;{DR>; zn2Ymg0W^E>NM-lZYBHS4^6qOkx#&(Vo=z^d z^M_Di5zNJloiCFN&;AApcqd()>`Y9za|brV(_k*1KEr~4>I@CT2cG-*KLb69xH`pT zz#DJ9ri$Tc4Psw@pe+7v^Md_+?|3-f3l1pPrM?J0?On38br*R2=GqkCOcVs6gT7+d ot%Ii6bvwgR0X8uV2S0w`*^gI4cTxD}!Tiq)zbv$aymxo=9|}->Bme*a delta 687 zcmZWm&ubGw6n^t#lWn@$#&)AcEmi0xUdJh@L$8X4=$WGjG2AzW3(Me$0GXe6O2tip2upIQ{t6 zdrc0_)lmc05eN`u5B7;o2vBH&pf5l$mrNMI39hqYQwlDfpg5VQz-EH?p`xA2Ooe1d zV-UK1H;O!eH++1t4GBLN-+d%U;DSvAjBL6CE_1mcTbLHq)|6sOaXY7!CY55j3zk(zu`IbKOPeyb_3;+|q@+!=SCccz!Dgv&^|HNCl!a2YAzh(Gb$hB6@k-L3F=Ov*bOQ|Q Qp!U+-e6=~&( delta 19 Zcmcb@afO3xIWI340}y0g-pJ*}0su5~1k?Zk diff --git a/server/src/app/__pycache__/main.cpython-311.pyc b/server/src/app/__pycache__/main.cpython-311.pyc index 590e08e42424692b47adcffb27639896d6c82804..1671d8720fd5da34a4c1892aa8c3e3ff8a651c30 100644 GIT binary patch delta 36 rcmeyt{ezo#IWI340}u#4UYWUZBkv3*MzPJynB15cIX1s#;bsH?%F_yA delta 36 rcmeyt{ezo#IWI340}#YrUYR*%Bkv3*M$yg7nB15c**3pr;bsH?&K?SW diff --git a/server/src/app/api/v1/__init__.py b/server/src/app/api/v1/__init__.py index d01ee60..37b1ddf 100644 --- a/server/src/app/api/v1/__init__.py +++ b/server/src/app/api/v1/__init__.py @@ -2,9 +2,9 @@ from fastapi import APIRouter from .knowledges import router as knowledge_router from .metrics import router as metric_router -from .users import router as user_router +from .auth import router as auth_router router = APIRouter(prefix="/v1") router.include_router(knowledge_router) router.include_router(metric_router) -router.include_router(user_router) \ No newline at end of file +router.include_router(auth_router) \ No newline at end of file diff --git a/server/src/app/api/v1/__pycache__/__init__.cpython-311.pyc b/server/src/app/api/v1/__pycache__/__init__.cpython-311.pyc index b0c6a39ec0309e84d9a56e833dc8d24c0b00a2e0..e682e78cf3ddf381cece4b979c8cc4377a68fb38 100644 GIT binary patch delta 59 zcmbQuI*XNeIWI340}!OXTA69FkvD^pn}ae)B^O?F_40s!_I B5xxKb diff --git a/server/src/app/api/v1/__pycache__/auth.cpython-311.pyc b/server/src/app/api/v1/__pycache__/auth.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b8dfa3e239fe1fe39e945c34327cce9714ed4c82 GIT binary patch literal 2640 zcmah~&2Jk;6rWwM*WPSgJF%UQ<^vNFf<+tC4+#*YN*bqWN}EGaQJ-W~ED}F;#Bxf$@U52d44)4{wjertxcu_xQ1eKr>QbNw$r}r4WO0N-C!p_{U zM~tWv z>Lc zhI*N8llipNb#qfpIO|kegZNUKYN=Et*eZ~0x(ysihzR2Wj2FKE`3P|UZ>wXyh;FrK z!1JKwv~A#?wr5*hkuyiFR+)f?s&=N6PxqiLMRYn}|ZD{OmUKa57Z&sl*MkC5gq za)(|)TXchEi?@P@+C^UT?fTvEz;#PYo1=@_bPiISwqh(bS=GR?9Er8kxfxnrT|LQe zw3T)$Ht)?t<;JC_(m4%NQNxy+(W!3(s~Y5(dd$L2mgq)SZ#FKQr`??wL%W>(r>uK< z9QPA;KI(79LH(^L2)h8nGDo8fcd4`QoJy@M&8{q8yn206nNJdSRuTdd_mD8t6POh; z0<6h07>mVTzMI&{88|_5H#6D96*ZgFGwMlI&u^#+(7laG!X)X0n$N??ByOKdFtknO z?@_OwThC<4IM`u+%sW7ShhGW(CJ&cyR7VnfgVj@W6**azlci)$4%U&^EAAf~+8-FL z4xFup&(xxmI|Fv)bloQe#pejfpN!OzAc=oYWANelh`qbQ|F?5nwpxEntqQ6wZy(2k_VM zh36CW*z=VDh-Ej`Y(-S$cR4p=w>(z6N)Re~+_tuaq5ucsm*PBm4Xn^0dl<0Rei{H8 z$3RZl$%zak?sXJNj0xUmgdG=>=R8B2^X8b$BcLbNNC*`hi{vDTUx#5{0@4J-aD3;j z%J7-$@EN=B)n2-~F9*x-?R{y>3l({xDle3h`{B{DRSAz*!{epPwZn`q#Yd?KC6URl z6P6O{TT`Lb@)^R?OISo56%lGKPMH{PJ!9P?>{%fa+ZYB!PXVH*3@B0EoN|hSouBr! zR#C$ z&a|AGqJbQ9b~h^u>FXYj z<7#NwcJ~7`ZU0}dq09DB{Q!;I?p{N2+uaY)qJ31ap`?9Ouc0?>cR!GN9}SlK%aSdP zRiv@1G*%K1IN#Sp_lF*RTH*StTwk4+xLL0JzCCg7neUnJN9iZYo>;67U8*Ct@N=Q@ z?WE5=i0^N2t@ojx2|F~tleI(BmC$rGG+hcXC&%v}f3#5HB2_L@=Q(bmeB)blXJKc- zKAWtZn6I9gwc) F-vPl)9)$n^ delta 90 zcmZ1_vQC6|IWI340}wEsU74A@k@q#bplESXvR-0AfnITHQCVhkYVl@P4mL)Of(r~p Jp~=Ra-vKuCARzz% diff --git a/server/src/app/api/v1/users.py b/server/src/app/api/v1/auth.py similarity index 85% rename from server/src/app/api/v1/users.py rename to server/src/app/api/v1/auth.py index eb64c49..f111dc8 100644 --- a/server/src/app/api/v1/users.py +++ b/server/src/app/api/v1/auth.py @@ -2,11 +2,13 @@ from typing import Annotated from fastapi import Depends, APIRouter, HTTPException, status from fastapi.security import OAuth2PasswordRequestForm, OAuth2PasswordBearer -from datetime import timedelta from src.app.models.user import User from src.app.data.user import create_user -from src.app.services.auth import get_current_user, authenticate_user, create_access_token, hash_password, Token + +from src.app.auth.dependancies import get_current_user, authenticate_user +from src.app.auth.security import hash_password, create_access_token +from src.app.auth.schemas import Token router = APIRouter(tags=["users"]) diff --git a/server/src/app/auth/__pycache__/auth.cpython-311.pyc b/server/src/app/auth/__pycache__/auth.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1204d9585289e4d677fc87a8416dbc439edca40c GIT binary patch literal 162 zcmZ3^%ge<81liwLW`gL)AOZ#$p^VRLK*n^26oz01O-8?!3`I;p{%4TnFH`-D{M=Oi zqWq-HJbmB9y!@QZMBT)kf{aA{;?$zD)FS=jqGbKVf&%@-(vl1?p;u7(i^C>2KczG$ d)vkyYXbQ-lVtyd;ftit!@dE>lC}IYR0RVP*COH5A literal 0 HcmV?d00001 diff --git a/server/src/app/auth/__pycache__/dependancies.cpython-311.pyc b/server/src/app/auth/__pycache__/dependancies.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..369a6408de32678b5d53ef77c2b27317e16a52e3 GIT binary patch literal 2503 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 rcyWf}$A6m$mft6X bool: - isValidated: bool = False - try: - return password_hasher.verify(hashed_password, plain_password) - except (VerifyMismatchError, VerificationError, InvalidHashError): - return False - -def create_access_token(data: dict): - expire = datetime.now(timezone.utc) + timedelta(minutes=access_token_expire_minutes) - to_encode = data.copy() - to_encode.update({"exp": expire}) - encoded_jwt = jwt.encode(to_encode, settings.SECRET_KEY, algorithm=algorithm) - return encoded_jwt - -async def hash_password(password: str) -> str: - return password_hasher.hash(password) - async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]) -> User: credentials_exception = HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, @@ -64,7 +33,7 @@ async def get_current_user(token: Annotated[str, Depends(oauth2_scheme)]) -> Use headers={"WWW-Authenticate": "Bearer"}, ) try: - payload = jwt.decode(token, settings.SECRET_KEY, algorithm=algorithm) + payload = jwt.decode(token, settings.SECRET_KEY, algorithm=settings.ALGORITHM) username = payload.get("sub") if username is None: raise credentials_exception diff --git a/server/src/app/auth/schemas.py b/server/src/app/auth/schemas.py new file mode 100644 index 0000000..1728652 --- /dev/null +++ b/server/src/app/auth/schemas.py @@ -0,0 +1,8 @@ +from pydantic import BaseModel + +class Token(BaseModel): + access_token: str + token_type: str + +class TokenData(BaseModel): + username: str | None = None \ No newline at end of file diff --git a/server/src/app/auth/security.py b/server/src/app/auth/security.py new file mode 100644 index 0000000..f180f94 --- /dev/null +++ b/server/src/app/auth/security.py @@ -0,0 +1,33 @@ +from src.app.config import settings +from datetime import timedelta, datetime, timezone +from argon2 import PasswordHasher +from argon2.exceptions import ( + VerifyMismatchError, + VerificationError, + InvalidHashError, +) +import jwt +from jwt.exceptions import InvalidTokenError + + +password_hasher = PasswordHasher() + +def verify_password(plain_password: str, hashed_password: str) -> bool: + try: + return password_hasher.verify(hashed_password, plain_password) + except (VerifyMismatchError, VerificationError, InvalidHashError): + return False + +def hash_password(password: str) -> str: + return password_hasher.hash(password) + +def create_access_token(data: dict): + expire = datetime.now(timezone.utc) + timedelta(minutes=settings.ACCESS_TOKEN_EXPIRE_MINUTES) + to_encode = data.copy() + to_encode.update({"exp": expire}) + encoded_jwt = jwt.encode(to_encode, settings.SECRET_KEY, algorithm=settings.ALGORITHM) + return encoded_jwt + +#def create_refresh_token(data: dict) -> str: + +#def verify_token(token: str, token_type: str = "access") -> Optional[dict]: \ No newline at end of file diff --git a/server/src/app/config.py b/server/src/app/config.py index 130233b..254a45a 100644 --- a/server/src/app/config.py +++ b/server/src/app/config.py @@ -1,17 +1,19 @@ from pydantic_settings import BaseSettings +from pydantic import Field class Settings(BaseSettings): # Database - DATABASE_URI: str + DATABASE_URI: str = Field("sqlite:///database.db", env='DATABASE_URI') # Language model - LANGUAGE_MODEL_API: str = "http://localhost:8080/v1" - LANGUAGE_MODEL_NAME: str = "SmolLM3-Q4_K_M.gguf" + LANGUAGE_MODEL_API: str = Field("http://localhost:8080/v1", env='LANGUAGE_MODEL_API') + LANGUAGE_MODEL_NAME: str = Field("SmolLM3-Q4_K_M.gguf", env='LANGUAGE_MODEL_NAME') # Security - ORIGIN: str - SECRET_KEY : str - ACCESS_TOKEN_EXPIRE_MINUTES: int + ORIGIN: str = Field('http://localhost:5173', env='ORIGIN') + SECRET_KEY : str = Field('random_string', env='SECRET_KEY') + ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 + ALGORITHM: str = "HS256" class Config: env_file = ".env" diff --git a/server/src/app/data/__init__.py b/server/src/app/data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/src/app/data/__pycache__/__init__.cpython-311.pyc b/server/src/app/data/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..346e8e6addc02f50badeea01df0780671abb2cf3 GIT binary patch literal 166 zcmZ3^%ge<81jnwd%mmSoK?DpiLK&agfQ;!3DGb33nv8xc8H$*I{LdiCUzYkA`MIh3 zMfpjYdHTMIdHFe+iMok71sRF@#i>PQsYUw5MalY!1qJ#ki6x2p@$s2?nI-Y@dIgog kIBatBQ%ZAE?TT1|CV}iK<_8iVm>C%vKQO?EB4(f%08$_)+W-In literal 0 HcmV?d00001 diff --git a/server/src/app/main.py b/server/src/app/main.py index 8f99323..a571bc7 100644 --- a/server/src/app/main.py +++ b/server/src/app/main.py @@ -6,7 +6,8 @@ from fastapi.middleware.cors import CORSMiddleware from src.app.database import create_db_and_tables -#TODO : best practice to manage models import +# Import models in app +# TODO : best practice to manage models import from src.app.models.question import Question from src.app.models.knowledge import Knowledge from src.app.models.metric import Metric @@ -14,7 +15,7 @@ from src.app.models.user import User from .api import router -#Test +#Fake data from src.app.faker_seed import faker #TODO : alternative @app.on_event("startup") ? diff --git a/server/src/app/models/__init__.py b/server/src/app/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/src/app/models/__pycache__/__init__.cpython-311.pyc b/server/src/app/models/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..da2a82fe923b9f34707e0081ebe692929b83c634 GIT binary patch literal 168 zcmZ3^%ge<81Xr)D%mmSoK?DpiLK&agfQ;!3DGb33nv8xc8H$*I{LdiCU)K5=`MIh3 zMfpjYdHTMIdHFe+iMok71sRF@#i>PQsYUw5MalY!1qJ%K`6;P6#rpB_nR%Hd@$q^E lmA^P_fP$qtsdh!IK(j!$74rj$56p~=j2{?aL=iJk3;@SNDAoV~ literal 0 HcmV?d00001 diff --git a/server/src/app/models/__pycache__/user.cpython-311.pyc b/server/src/app/models/__pycache__/user.cpython-311.pyc index 4e0f82c8a252159d8b7433e6a3fe0a6d1b5b2d44..3fe7359a1e1cced35fab3506889f0274d99e8a65 100644 GIT binary patch delta 22 ccmcb^dWV&FIWI340}yO{x-#>^M&9#G08l3fq5uE@ delta 22 ccmcb^dWV&FIWI340}vR_S(&+eBky@807&)*!~g&Q diff --git a/server/src/app/models/user.py b/server/src/app/models/user.py index 355d511..48a4191 100644 --- a/server/src/app/models/user.py +++ b/server/src/app/models/user.py @@ -3,4 +3,5 @@ from sqlmodel import Field, SQLModel, Relationship class User(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) username: str - hashed_password: str \ No newline at end of file + hashed_password: str + #is_active: bool \ No newline at end of file diff --git a/server/src/app/services/__pycache__/language_generation.cpython-311.pyc b/server/src/app/services/__pycache__/language_generation.cpython-311.pyc index c72f82217d215ead72f5124922a0fb34bef737a1..905c0d04c20617942924075ead9732837b1cd6e8 100644 GIT binary patch delta 19 ZcmaFQ_nwbyIWI340}#kQ-pG~84gfdC1or>{ delta 19 ZcmaFQ_nwbyIWI340}$|E*~pd34gfbN1lj-q