Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
eb8caaa
feat(auth): add Redis caching for unverified users and update environ…
mantle-bearer Mar 1, 2025
b2ac1d9
feat(deps): add Redis as a dependency for caching functionality
mantle-bearer Mar 1, 2025
5d23275
feat(auth): restructure user data response and update token verificat…
mantle-bearer Mar 1, 2025
1fc3140
feat(auth): add is_superadmin field to user registration and update v…
mantle-bearer Mar 1, 2025
8159e95
Merge branch 'dev' into feat/auth-caching-unverified-users
mantle-bearer Mar 1, 2025
c25ead2
feat(auth): update environment .env.sample
mantle-bearer Mar 1, 2025
34c7c22
feat(env): update Redis configuration in .env.sample
mantle-bearer Mar 1, 2025
b96211e
feat(env): update email configuration in .env.sample
mantle-bearer Mar 1, 2025
408c9bc
Merge branch 'dev' into feat/auth-caching-unverified-users
mantle-bearer Mar 1, 2025
4b41bb5
feat(test): add access token generation for user registration and enh…
mantle-bearer Mar 1, 2025
fe928da
Merge branch 'dev' into feat/auth-caching-unverified-users
mantle-bearer Mar 1, 2025
40bf937
Merge branch 'dev' into feat/auth-caching-unverified-users
mantle-bearer Mar 1, 2025
5529ccb
feat(auth): update test file
mantle-bearer Mar 1, 2025
5a62d5d
refactor(test): clean up whitespace in super admin creation test
mantle-bearer Mar 1, 2025
2233072
refactor(auth): remove merge conflict markers and clean up imports
mantle-bearer Mar 1, 2025
3e0f3e3
feat(auth): add endpoints for setting up, enabling, and disabling TOT…
mantle-bearer Mar 1, 2025
13100dd
feat(auth): verify 2FA status during user login process
mantle-bearer Mar 1, 2025
d0e3fc1
feat(config): update frontend URL and add configurable port number
mantle-bearer Mar 1, 2025
9178487
feat(config): add configurable server port number to settings
mantle-bearer Mar 1, 2025
a4eafbd
feat(config): add server port number to .env.sample
mantle-bearer Mar 1, 2025
201fc52
feat(config): update .env.sample with placeholder values for sensitiv…
mantle-bearer Mar 2, 2025
446c2b8
refactor(user): remove unused create_registration_access_token method
mantle-bearer Mar 2, 2025
a827a66
refactor(redis): replace direct Redis client initialization with a la…
mantle-bearer Mar 2, 2025
e11634e
feat(config): update .env.sample with default Redis port and database…
mantle-bearer Mar 2, 2025
b75b182
Merge branch 'dev' into feat/auth-caching-unverified-users
mantle-bearer Mar 2, 2025
510f560
docs(auth): clarify comment on token generation in login function
mantle-bearer Mar 2, 2025
9cdbfc1
refactor(auth): replace print statements with logger for token genera…
mantle-bearer Mar 2, 2025
d07c467
feat(ci): add Redis service configuration to CI workflow
mantle-bearer Mar 2, 2025
6990985
feat(ci): update Redis service configuration in CI workflow
mantle-bearer Mar 2, 2025
808514c
feat(ci): update Redis host and port in CI workflow
mantle-bearer Mar 2, 2025
b78ee6f
feat(ci): use secrets for Redis configuration in CI workflow
mantle-bearer Mar 2, 2025
552996c
feat(ci): move Redis configuration to environment variables in CI wor…
mantle-bearer Mar 2, 2025
6f06942
Merge branch 'dev' into feat/auth-caching-unverified-users
mantle-bearer Mar 2, 2025
c04ae03
feat(ci): update CI workflow to use secrets for Redis configuration a…
mantle-bearer Mar 2, 2025
06ad020
feat(ci): add Redis service and environment variables for CI workflow
mantle-bearer Mar 2, 2025
17025ae
feat(ci): remove unused Redis environment variables from CI workflow
mantle-bearer Mar 2, 2025
7b457fc
test: mock Redis client in user registration tests
mantle-bearer Mar 2, 2025
6410507
test: enhance Redis connection handling in user registration tests
mantle-bearer Mar 2, 2025
ef8aabc
test: update assertions in user creation tests to accommodate Redis h…
mantle-bearer Mar 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ DB_HOST="localhost"
DB_PORT=5432
MYSQL_DRIVER=
DB_URL=postgresql://username:password@localhost:5432/test
SECRET_KEY = ""
ALGORITHM = HS256
ACCESS_TOKEN_EXPIRE_MINUTES = 3000
SECRET_KEY=""
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=3000
JWT_REFRESH_EXPIRY=7
APP_URL=

GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""

FRONTEND_URL='http://127.0.0.1:3000/login-success'
FRONTEND_URL='https://python-fastapi.boilerplate.hng.tech'

SERVER_PORT_NUMBER=7001

TESTING=''

MAIL_USERNAME=""
MAIL_PASSWORD=""
MAIL_USERNAME="MAIL_USERNAME"
MAIL_PASSWORD="MAIL_PASSWORD"
MAIL_FROM="[email protected]"
MAIL_PORT=465
MAIL_SERVER="smtp.gmail.com"
Expand All @@ -40,6 +42,14 @@ STRIPE_WEBHOOK_SECRET=""
MAILJET_API_KEY='MAIL JET API KEY'
MAILJET_API_SECRET='SECRET KEY'


REDIS_HOST='REDIS_HOST'
REDIS_PORT='REDIS_PORT'
REDIS_PASSWORD='REDIS_PASSWORD'
REDIS_DB='REDIS_DB'

APP_NAME="fastapi_boilerplate"


TELEX_WEBHOOK_URL=""

12 changes: 5 additions & 7 deletions api/core/dependencies/email/templates/email-verification.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{% extends 'base.html' %}

{% block title %}Email Verification{% endblock %}
{% block style %}<link rel="stylesheet" href="{{ url_for('email_static', path='css/email-verification.css') }}">{% endblock %}
{% block style %}
<link rel="stylesheet" href="{{ url_for('email_static', path='css/email-verification.css') }}">{% endblock %}

{% block content %}
<div class="template-main">
<div class="heading">
<p class="template-header">Email Verification</p>
</div>
<div class="content">
<p class="template-receiver-name">Hi John Doe,</p>
<p class="template-receiver-name">Hi {{first_name}}, {{last_name}}</p>
<p class="template-message">
Thanks for registering your account with us Boilerplate. Before we get
started, we just need to confirm that this is you.
Expand All @@ -23,11 +24,8 @@
<button class="template-btn">Verify Account</button>
<p>
Or copy this link:
<a
href="https://carbonated-umbra-a35.notion.site/Language-Learning-AI-game-608b687875cf4b48a9a0194ee82ae17d"
class="copy-link"
>
https://carbonated-umbra-a35.notion.site/Language-Learning-AI-game-608b687875cf4b48a9a0194ee82ae17d
<a href="{{ cta_link }}" class="copy-link">
{{ cta_link }}
</a>
</p>
<div class="template-farewell">
Expand Down
11 changes: 11 additions & 0 deletions api/core/dependencies/redis_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import redis
from api.utils.settings import settings

# Initialize Redis connection
redis_client = redis.StrictRedis(
host=settings.REDIS_HOST,
port=settings.REDIS_PORT,
password=settings.REDIS_PASSWORD,
db=settings.REDIS_DB,
decode_responses=True
)
10 changes: 10 additions & 0 deletions api/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ class Settings(BaseSettings):
ACCESS_TOKEN_EXPIRE_MINUTES: int = config("ACCESS_TOKEN_EXPIRE_MINUTES")
JWT_REFRESH_EXPIRY: int = config("JWT_REFRESH_EXPIRY")

# Redis configurations
REDIS_HOST: str = config("REDIS_HOST")
REDIS_DB: int = config("REDIS_DB", cast=int)
REDIS_PORT: int = config("REDIS_PORT", cast=int)
REDIS_PASSWORD: str = config("REDIS_PASSWORD")

FRONTEND_URL: str = config("FRONTEND_URL")
SERVER_PORT_NUMBER: int = config("SERVER_PORT_NUMBER", cast=int)


# Database configurations
DB_HOST: str = config("DB_HOST")
DB_PORT: int = config("DB_PORT", cast=int)
Expand Down
1 change: 1 addition & 0 deletions api/utils/success_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def success_response(status_code: int, message: str, data: Optional[dict] = None
"status_code": status_code,
"message": message,
"data": data or {} # Ensure data is always a dictionary

}

return JSONResponse(status_code=status_code, content=jsonable_encoder(response_data))
Expand Down
Loading
Loading