-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from JohnGrubba/dev
Internal Columns and Docker Optimizations
- Loading branch information
Showing
15 changed files
with
126 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Empty file.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
FROM python:3.12 | ||
FROM python:3.12-slim | ||
|
||
WORKDIR /src/app | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
WORKDIR /src/app | ||
|
||
COPY ./requirements.txt /src/app/requirements.txt | ||
|
||
RUN pip install --no-cache-dir --upgrade -r /src/app/requirements.txt | ||
|
||
COPY . /src/app | ||
|
||
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "80", "--log-level", "info"] | ||
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "80", "--log-level", "critical"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from fastapi import HTTPException, Cookie | ||
from tools import SessionConfig, InternalConfig | ||
from tools import users_collection, sessions_collection | ||
import logging | ||
|
||
|
||
async def get_pub_user( | ||
session_token: str = Cookie(default=None, alias=SessionConfig.auto_cookie_name) | ||
): | ||
if not session_token: | ||
logging.debug("No session token") | ||
raise HTTPException(status_code=401) | ||
session = sessions_collection.find_one({"session_token": session_token}) | ||
if not session: | ||
logging.debug("No session found") | ||
raise HTTPException(status_code=401) | ||
user = users_collection.find_one( | ||
{"_id": session["user_id"]}, InternalConfig.internal_columns | ||
) | ||
if not user: | ||
logging.debug("No user for session found") | ||
raise HTTPException(status_code=401) | ||
return user |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from fastapi import APIRouter, Depends | ||
from api.dependencies.authenticated import get_pub_user | ||
|
||
|
||
router = APIRouter( | ||
prefix="/profile", | ||
tags=["Profile"], | ||
dependencies=[Depends(get_pub_user)], | ||
) | ||
|
||
|
||
@router.get("/") | ||
async def profile(user: dict = Depends(get_pub_user)): | ||
""" | ||
# Get Profile Information | ||
## Description | ||
This endpoint is used to get the public profile information of the user. | ||
""" | ||
return user |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
from .db import users_collection, sessions_collection, insecure_cols | ||
from .conf import SignupConfig, EmailConfig, SessionConfig, InternalConfig | ||
from .db import users_collection, sessions_collection | ||
from .conf import ( | ||
SignupConfig, | ||
EmailConfig, | ||
SessionConfig, | ||
InternalConfig, | ||
AccountFeaturesConfig, | ||
) | ||
from .mail import send_email, broadcast_emails |
This file contains 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
This file contains 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
This file contains 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