Backend prasanna - #12
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an initial FastAPI backend foundation for the Malware Classification System, including user authentication (register/login), JWT security utilities, and SQLAlchemy persistence, plus README improvements.
Changes:
- Expanded README with objectives, team structure, docs index, and current status.
- Added backend auth stack: User model + Pydantic schemas, auth services, JWT/password security utilities, and auth/profile API routes.
- Added middleware for extracting the current user from a JWT and configured the FastAPI app (CORS + router registration).
Reviewed changes
Copilot reviewed 19 out of 37 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Expands project overview, objectives, documentation index, and status. |
| backend/requirements.txt | Adds email validation and httpx dependency for backend needs. |
| backend/app/main.py | Introduces FastAPI app initialization, CORS configuration, and router registration. |
| backend/app/api/auth.py | Adds auth endpoints (register/login) and profile endpoints. |
| backend/app/api/init.py | Exposes API router(s). |
| backend/app/core/config.py | Adds application settings including JWT configuration. |
| backend/app/core/security.py | Adds password hashing + JWT creation/verification utilities. |
| backend/app/core/init.py | Re-exports core settings/security helpers. |
| backend/app/db/session.py | Adds SQLAlchemy engine/session setup and request-scoped DB dependency. |
| backend/app/db/init.py | Re-exports DB helpers. |
| backend/app/models/user.py | Adds SQLAlchemy User model. |
| backend/app/models/init.py | Exposes model(s). |
| backend/app/schemas/user.py | Adds Pydantic schemas for user create/update/response. |
| backend/app/schemas/auth.py | Adds auth/token-related Pydantic schemas. |
| backend/app/schemas/init.py | Exposes schema(s). |
| backend/app/services/auth_service.py | Implements user lookup, registration, authentication, and profile update service logic. |
| backend/app/services/init.py | Re-exports service functions. |
| backend/app/middleware/auth_middleware.py | Adds get_current_user dependency for JWT-protected routes. |
| backend/app/middleware/init.py | Exposes middleware helpers. |
Suppressed comments (1)
backend/app/services/auth_service.py:66
update_user_profileallows changinguser.rolevia the normal profile update flow, enabling privilege escalation for any authenticated user. Role changes should be disallowed here or restricted to a separate admin-only endpoint.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| typing_extensions==4.16.0 | ||
| uvicorn==0.52.0 | ||
| email-validator==2.2.0 | ||
| httpx>=0.27.0 |
Comment on lines
+4
to
+9
| from app.api.auth import router as auth_router | ||
| from app.core.config import settings | ||
| from app.db.session import Base, engine | ||
|
|
||
| # Automatically initialize database tables on startup | ||
| Base.metadata.create_all(bind=engine) |
Comment on lines
+22
to
+25
| allow_origins=["*"], # Restrict in production environment | ||
| allow_credentials=True, | ||
| allow_methods=["*"], | ||
| allow_headers=["*"], |
| username=user_in.username, | ||
| hashed_password=hashed_pwd, | ||
| full_name=user_in.full_name, | ||
| role=user_in.role |
Comment on lines
+128
to
+132
| except ValueError as e: | ||
| raise HTTPException( | ||
| status_code=status.HTTP_400_BAD_REQUEST, | ||
| detail=str(e) | ||
| ) |
Comment on lines
+9
to
+10
| from app.schemas.auth import LoginRequest, Token | ||
| from app.schemas.user import UserCreate, UserResponse, UserUpdate |
Comment on lines
+10
to
+16
| # JWT Cryptographic Configuration | ||
| SECRET_KEY: str = os.getenv("SECRET_KEY", "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7") | ||
| ALGORITHM: str = "HS256" | ||
| ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 | ||
|
|
||
|
|
||
| settings = Settings() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.