Commit ·
ec0faef
0
Parent(s):
Initial commit: Setup Expo frontend and FastAPI backend scaffolding
Browse files- .gitattributes +5 -0
- .gitignore +12 -0
- keystone-app +1 -0
- keystone-backend/.gitignore +42 -0
- keystone-backend/main.py +61 -0
.gitattributes
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ico filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Environments
|
| 2 |
+
.env
|
| 3 |
+
venv/
|
| 4 |
+
__pycache__/
|
| 5 |
+
|
| 6 |
+
# Node
|
| 7 |
+
node_modules/
|
| 8 |
+
.expo/
|
| 9 |
+
|
| 10 |
+
# OS Files
|
| 11 |
+
.DS_Store
|
| 12 |
+
Thumbs.db
|
keystone-app
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Subproject commit 4444c8c86200e22e1ae48006c96c40920fb4c94d
|
keystone-backend/.gitignore
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
|
| 2 |
+
|
| 3 |
+
# dependencies
|
| 4 |
+
node_modules/
|
| 5 |
+
|
| 6 |
+
# Expo
|
| 7 |
+
.expo/
|
| 8 |
+
dist/
|
| 9 |
+
web-build/
|
| 10 |
+
expo-env.d.ts
|
| 11 |
+
|
| 12 |
+
# Native
|
| 13 |
+
.kotlin/
|
| 14 |
+
*.orig.*
|
| 15 |
+
*.jks
|
| 16 |
+
*.p8
|
| 17 |
+
*.p12
|
| 18 |
+
*.key
|
| 19 |
+
*.mobileprovision
|
| 20 |
+
|
| 21 |
+
# Metro
|
| 22 |
+
.metro-health-check*
|
| 23 |
+
|
| 24 |
+
# debug
|
| 25 |
+
npm-debug.*
|
| 26 |
+
yarn-debug.*
|
| 27 |
+
yarn-error.*
|
| 28 |
+
|
| 29 |
+
# macOS
|
| 30 |
+
.DS_Store
|
| 31 |
+
*.pem
|
| 32 |
+
|
| 33 |
+
# local env files
|
| 34 |
+
.env*.local
|
| 35 |
+
.env
|
| 36 |
+
venv/
|
| 37 |
+
# typescript
|
| 38 |
+
*.tsbuildinfo
|
| 39 |
+
|
| 40 |
+
# generated native folders
|
| 41 |
+
/ios
|
| 42 |
+
/android
|
keystone-backend/main.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from fastapi import FastAPI, HTTPException, Header, Depends
|
| 3 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
+
from pydantic import BaseModel
|
| 5 |
+
from dotenv import load_dotenv
|
| 6 |
+
|
| 7 |
+
# Load environment variables
|
| 8 |
+
load_dotenv()
|
| 9 |
+
|
| 10 |
+
app = FastAPI(title="KeyStone API", version="0.1.0")
|
| 11 |
+
|
| 12 |
+
# Fetch credentials from environment variables
|
| 13 |
+
DEV_USERNAME = os.getenv("DEV_USERNAME", "admin")
|
| 14 |
+
DEV_PASSWORD = os.getenv("DEV_LOGIN_PASSWORD", "password123")
|
| 15 |
+
MOCK_TOKEN = "mock-jwt-token-xyz123"
|
| 16 |
+
|
| 17 |
+
app.add_middleware(
|
| 18 |
+
CORSMiddleware,
|
| 19 |
+
allow_origins=["*"],
|
| 20 |
+
allow_credentials=True,
|
| 21 |
+
allow_methods=["*"],
|
| 22 |
+
allow_headers=["*"],
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Updated schema to look for username instead of email
|
| 26 |
+
class LoginPayload(BaseModel):
|
| 27 |
+
username: str
|
| 28 |
+
password: str
|
| 29 |
+
|
| 30 |
+
def verify_mock_token(authorization: str = Header(None)):
|
| 31 |
+
if not authorization or not authorization.startswith("Bearer "):
|
| 32 |
+
raise HTTPException(status_code=401, detail="Missing or invalid token format")
|
| 33 |
+
|
| 34 |
+
token = authorization.split(" ")[1]
|
| 35 |
+
if token != MOCK_TOKEN:
|
| 36 |
+
raise HTTPException(status_code=401, detail="Unauthorized: Invalid Token")
|
| 37 |
+
return token
|
| 38 |
+
|
| 39 |
+
@app.get("/health")
|
| 40 |
+
async def health_check():
|
| 41 |
+
return {"status": "ok", "service": "KeyStone API"}
|
| 42 |
+
|
| 43 |
+
@app.post("/auth/login")
|
| 44 |
+
async def mock_login(payload: LoginPayload):
|
| 45 |
+
# Strict matching for both username AND password
|
| 46 |
+
if payload.username == DEV_USERNAME and payload.password == DEV_PASSWORD:
|
| 47 |
+
return {
|
| 48 |
+
"access_token": MOCK_TOKEN,
|
| 49 |
+
"token_type": "bearer",
|
| 50 |
+
"user": {"username": payload.username, "id": "mock-uuid-1111-2222"}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
# Generic error message so we don't leak which field was incorrect
|
| 54 |
+
raise HTTPException(status_code=400, detail="Incorrect username or password")
|
| 55 |
+
|
| 56 |
+
@app.get("/photos")
|
| 57 |
+
async def get_photos(token: str = Depends(verify_mock_token)):
|
| 58 |
+
return {
|
| 59 |
+
"message": "Authenticated successfully!",
|
| 60 |
+
"photos": []
|
| 61 |
+
}
|