Skip to content

Commit 3987d99

Browse files
committed
Created scripts, code and documentation for client and server.
1 parent efdd681 commit 3987d99

File tree

69 files changed

+391
-355
lines changed

Some content is hidden

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

69 files changed

+391
-355
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: 221 additions & 22 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: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
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
14+
SCOPES: str
1615

1716
class Config:
18-
env_file = ".env_oauth"
17+
env_file = "client/.env_oauth"
1918

2019

2120
def initialize_oauth_settings():
2221
try:
2322
# Create an instance of OAuthSettings
24-
internal_oauth_settings = OAuthSettings()
23+
settings = OAuthSettings()
2524

2625
# 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.")
26+
if not settings.AZURE_CLIENT_ID or not settings.AZURE_CLIENT_SECRET \
27+
or not settings.AZURE_TENANT_ID or not settings.REDIRECT_URI\
28+
or not settings.SCOPES:
29+
logger.error("One or more required OAuth environment variables are missing.")
2930
raise HTTPException(status_code=500,
3031
detail="Configuration error: Required OAuth environment variables are missing.")
3132

32-
logger.logger.info("OAuth settings loaded successfully.")
33-
return internal_oauth_settings
33+
logger.info("OAuth settings loaded successfully.")
34+
return settings
3435
except FileNotFoundError:
35-
logger.logger.critical(".env file not found.")
36+
logger.critical(".env file not found.")
3637
raise HTTPException(status_code=500, detail="Configuration error: .env file not found.")
3738
except Exception as e:
38-
logger.logger.critical(f"Error loading OAuth settings: {e}")
39+
logger.critical(f"Error loading OAuth settings: {e}")
3940
raise HTTPException(status_code=500,
4041
detail="Configuration error: An error occurred while loading OAuth settings.")
4142

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)