Skip to content

Commit 8ab0d74

Browse files
committed
Implemented client and updated README
1 parent efdd681 commit 8ab0d74

File tree

62 files changed

+326
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+326
-346
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/.env_oauth
1+
client/.env_oauth
22
/infra/terraform.tfvars
33
/.idea/.gitignore
44
/infra/.terraform.lock.hcl

README.md

Lines changed: 179 additions & 17 deletions
Large diffs are not rendered by default.

client/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

client/config/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# client/config/__init__.py
2-
31
from .oauth import oauth_settings
42

53
__all__ = ["oauth_settings"]

client/config/oauth.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
# client/config/oauth.py
2-
31
from dotenv import load_dotenv
42
from fastapi import HTTPException
53
from pydantic_settings import BaseSettings
6-
from client import logger
4+
from client.logger import logger
75

86
load_dotenv()
97

8+
109
class OAuthSettings(BaseSettings):
1110
AZURE_CLIENT_ID: str
1211
AZURE_CLIENT_SECRET: str
1312
AZURE_TENANT_ID: str
14-
API_SCOPE: str
1513
REDIRECT_URI: str
1614

1715
class Config:
@@ -21,21 +19,21 @@ class Config:
2119
def initialize_oauth_settings():
2220
try:
2321
# Create an instance of OAuthSettings
24-
internal_oauth_settings = OAuthSettings()
22+
settings = OAuthSettings()
2523

2624
# Check if the required OAuth fields are set
27-
if not internal_oauth_settings.AZURE_CLIENT_ID or not internal_oauth_settings.AZURE_CLIENT_SECRET or not internal_oauth_settings.AZURE_TENANT_ID or not internal_oauth_settings.API_SCOPE:
28-
logger.logger.error("One or more required OAuth environment variables are missing.")
25+
if not settings.AZURE_CLIENT_ID or not settings.AZURE_CLIENT_SECRET or not settings.AZURE_TENANT_ID:
26+
logger.error("One or more required OAuth environment variables are missing.")
2927
raise HTTPException(status_code=500,
3028
detail="Configuration error: Required OAuth environment variables are missing.")
3129

32-
logger.logger.info("OAuth settings loaded successfully.")
33-
return internal_oauth_settings
30+
logger.info("OAuth settings loaded successfully.")
31+
return settings
3432
except FileNotFoundError:
35-
logger.logger.critical(".env file not found.")
33+
logger.critical(".env file not found.")
3634
raise HTTPException(status_code=500, detail="Configuration error: .env file not found.")
3735
except Exception as e:
38-
logger.logger.critical(f"Error loading OAuth settings: {e}")
36+
logger.critical(f"Error loading OAuth settings: {e}")
3937
raise HTTPException(status_code=500,
4038
detail="Configuration error: An error occurred while loading OAuth settings.")
4139

client/logger.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

client/logger/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .logger import logger
2+
3+
__all__ = ["logger"]

client/logger/logger.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import logging
2+
3+
logging.basicConfig(
4+
level=logging.INFO,
5+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
6+
)
7+
8+
logger = logging.getLogger("logger")

client/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from client.routers import auth, heroes
55

66
app = FastAPI(
7-
title="Hero API",
8-
description="An API to manage heroes secure by OAuth 2.0 auth code flow",
7+
title="Hvalfangst Client",
8+
description="Client accessing our server deployed on Azure Web Apps secured by OAuth 2.0 authorization code flow with OIDC",
99
version="1.0.0"
1010
)
1111

client/models/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# client/models/__init__.py
1+
from .hero import Hero
22

3-
from .dnd_hero import DnDHero, AbilityScores, SkillProficiencies, Equipment, Spell
4-
5-
__all__ = ["DnDHero", "AbilityScores", "SkillProficiencies", "Equipment", "Spell"]
3+
__all__ = ["Hero"]

0 commit comments

Comments
 (0)