Skip to content

Commit

Permalink
Fixed apple wallet, added config for apple pki dir
Browse files Browse the repository at this point in the history
  • Loading branch information
jontyms committed Aug 22, 2024
1 parent 9d2c656 commit 81564ff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
21 changes: 16 additions & 5 deletions app/routes/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,22 @@ def apple_wallet(user_data):
p.add_to_pass_package(("pass.json", pass_data))

# Add locally stored credentials
with open(
os.path.join(os.path.dirname(__file__), "..", "config/pki/hackucf.key"), "rb"
) as key, open(
os.path.join(os.path.dirname(__file__), "..", "config/pki/hackucf.pem"), "rb"
) as cert:
key_path = Settings().apple_wallet.pki_dir / "hackucf.key"
cert_path = (
Settings().apple_wallet.pki_dir / "hackucf.pem"
) # Assuming a different cert file

# Check if files exist before opening them
if not key_path.exists():
logger.error(f"File not found: {key_path}")
raise FileNotFoundError(f"File not found: {key_path}")

if not cert_path.exists():
logger.error(f"File not found: {cert_path}")
raise FileNotFoundError(f"File not found: {cert_path}")

# Open the files
with key_path.open("rb") as key, cert_path.open("rb") as cert:
# Add credentials to pass package
p.key = key.read()
p.cert = cert.read()
Expand Down
8 changes: 8 additions & 0 deletions app/util/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ class TelemetryConfig(BaseModel):
telemetry_config = TelemetryConfig(**settings.get("telemetry", {}))


class AppleWalletConfig(BaseModel):
pki_dir: Optional[pathlib.Path] = Field(None)


apple_wallet_config = AppleWalletConfig(**settings.get("apple_wallet", {}))


class DatabaseConfig(BaseModel):
url: str

Expand Down Expand Up @@ -388,4 +395,5 @@ class Settings(BaseSettings, metaclass=SingletonBaseSettingsMeta):
keycloak: KeycloakConfig = keycloak_config
google_wallet: GoogleWalletConfig = google_wallet_config
telemetry: Optional[TelemetryConfig] = telemetry_config
apple_wallet: AppleWalletConfig = apple_wallet_config
env: Optional[str] = onboard_env
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
airpress==1.0.3
asyncio==3.4.3
cryptography==39.0.1
cryptography==38.0.0
commonmark==0.9.1
fastapi[standard]==0.112.1
Jinja2==3.1.4
passwordgenerator==1.5.1
pyOpenSSL==23.2.0
pyOpenSSL==22.1.0
pydantic==2.8.2
pydantic_settings==2.4.0
python-dateutil==2.9.0.post0
Expand Down

0 comments on commit 81564ff

Please sign in to comment.