Skip to content

Commit 2d23a80

Browse files
feat: add auth0 configs
1 parent b0b0b3e commit 2d23a80

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

backend/.env.example

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,15 @@ AI_MODEL=
2323
AI_API_KEY=
2424

2525
COLLECTION_GENERATION_PROMPT="I want to generate flashcards on a specific topic for efficient studying. Please create a set of flashcards covering key concepts, definitions, important details, and examples, with a focus on progressively building understanding of the topic. The flashcards should aim to provide a helpful learning experience by using structured explanations, real-world examples and formatting. Each flashcard should follow this format: Front (Question/Prompt): A clear and concise question or term to test recall, starting with introductory concepts and moving toward more complex details. Back (Answer): If the front is a concept or topic, provide a detailed explanation, broken down into clear paragraphs with easy-to-understand language. If possible, include a real-world example, analogy or illustrative diagrams to make the concept more memorable and relatable. If the front is a vocabulary word (for language learning), provide a direct translation in the target language. Optional Hint: A short clue to aid recall, especially for more complex concepts. Important: Use valid Markdown format for the back of the flashcard."
26-
CARD_GENERATION_PROMPT="I want to generate a flashcard on a specific topic. The contents of the flashcard should provide helpful information that aim to help the learner retain the concepts given. The flashcard must follow this format: Front (Question/Prompt): A clear and concise question or term to test recall. Back (Answer): If the front is a concept or topic, provide a detailed explanation, broken down into clear paragraphs with easy-to-understand language. If possible, include a real-world example, analogy or illustrative diagrams to make the concept more memorable and relatable. If the front is a vocabulary word (for language learning), provide a direct translation in the target language. Important: Use valid Markdown format for the back of the flashcard."
26+
CARD_GENERATION_PROMPT="I want to generate a flashcard on a specific topic. The contents of the flashcard should provide helpful information that aim to help the learner retain the concepts given. The flashcard must follow this format: Front (Question/Prompt): A clear and concise question or term to test recall. Back (Answer): If the front is a concept or topic, provide a detailed explanation, broken down into clear paragraphs with easy-to-understand language. If possible, include a real-world example, analogy or illustrative diagrams to make the concept more memorable and relatable. If the front is a vocabulary word (for language learning), provide a direct translation in the target language. Important: Use valid Markdown format for the back of the flashcard."
27+
28+
# Auth0 Configuration
29+
AUTH0_DOMAIN=auth0-domain
30+
AUTH0_CLIENT_ID=auth0-client-id
31+
AUTH0_CLIENT_SECRET=auth0-client-secret
32+
AUTH0_AUDIENCE=auth0-audience
33+
AUTH0_CALLBACK_URL=auth0-callback-url
34+
AUTH_LOGOUT_URL=auth-logout-url
35+
36+
# Session Configuration
37+
SECRET_KEY=secret-key

backend/src/core/config.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ class Settings(BaseSettings):
4646
POSTGRES_PASSWORD: str
4747
POSTGRES_DB: str = ""
4848

49+
# Auth0 Configuration
50+
AUTH0_CLIENT_ID: str
51+
AUTH0_CLIENT_SECRET: str
52+
AUTH0_ISSUER: str
53+
AUTH0_CALLBACK_URL: str
54+
AUTH0_LOGOUT_URL: str
55+
AUTH0_AUDIENCE: str
56+
57+
# Session Configuration
58+
SESSION_MAX_AGE: int = 60 * 60 * 24 * 7 # 7 days
59+
4960
@computed_field # type: ignore[misc]
5061
@property
5162
def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn:
@@ -91,8 +102,33 @@ def _enforce_non_default_secrets(self) -> Self:
91102
self._check_default_secret(
92103
"FIRST_SUPERUSER_PASSWORD", self.FIRST_SUPERUSER_PASSWORD
93104
)
105+
self._check_default_secret("AUTH0_CLIENT_SECRET", self.AUTH0_CLIENT_SECRET)
94106

95107
return self
96108

109+
@computed_field # type: ignore[prop-decorator]
110+
@property
111+
def auth0_jwks_url(self) -> str:
112+
"""Get the JWKS URL for token validation."""
113+
return f"https://{self.AUTH0_DOMAIN}/.well-known/jwks.json"
114+
115+
@computed_field # type: ignore[prop-decorator]
116+
@property
117+
def auth0_authorization_url(self) -> str:
118+
"""Get the authorization URL for login."""
119+
return f"https://{self.AUTH0_DOMAIN}/authorize"
120+
121+
@computed_field # type: ignore[prop-decorator]
122+
@property
123+
def auth0_token_url(self) -> str:
124+
"""Get the token URL for token exchange."""
125+
return f"https://{self.AUTH0_DOMAIN}/oauth/token"
126+
127+
@computed_field # type: ignore[prop-decorator]
128+
@property
129+
def auth0_userinfo_url(self) -> str:
130+
"""Get the userinfo URL for fetching user data."""
131+
return f"https://{self.AUTH0_DOMAIN}/userinfo"
132+
97133

98134
settings = Settings() # type: ignore

0 commit comments

Comments
 (0)