Skip to content

Commit

Permalink
feat: support locally auth
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai committed Dec 17, 2024
1 parent c4dbcb5 commit 178c432
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions server/.env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ X_GITHUB_APPS_CLIENT_SECRET=github_apps_client_secret
# OPTIONAL - Local Authorization Configures
PETERCAT_LOCAL_UID="petercat|001"
PETERCAT_LOCAL_UNAME="petercat"
PETERCAT_LOCAL_GITHUB_TOKEN="github_pat_xxxx"

# OPTIONAL - SKIP AUTH0 Authorization
PETERCAT_AUTH0_ENABLED=True
Expand Down
6 changes: 5 additions & 1 deletion server/auth/clients/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

PETERCAT_LOCAL_UID = get_env_variable("PETERCAT_LOCAL_UID")
PETERCAT_LOCAL_UNAME = get_env_variable("PETERCAT_LOCAL_UNAME")
PETERCAT_LOCAL_GITHUB_TOKEN = get_env_variable("PETERCAT_LOCAL_GITHUB_TOKEN")
WEB_URL = get_env_variable("WEB_URL")
WEB_LOGIN_SUCCESS_URL = f"{WEB_URL}/user/login"

Expand All @@ -21,7 +22,7 @@ async def login(self, request: Request):

return RedirectResponse(url=f"{WEB_LOGIN_SUCCESS_URL}", status_code=302)

async def get_user_info(user_id):
async def get_user_info(self, user_id):
token = PETERCAT_LOCAL_UID
username = PETERCAT_LOCAL_UNAME
seed = token[:4]
Expand All @@ -36,3 +37,6 @@ async def get_user_info(user_id):
"agreement_accepted": False,
}


async def get_access_token(self, user_id):
return PETERCAT_LOCAL_GITHUB_TOKEN
4 changes: 1 addition & 3 deletions server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,11 @@ def home_page():

@app.get("/api/health_checker")
def health_checker():
supabase_url = get_env_variable("SUPABASE_URL")
return {
"ENVIRONMENT": ENVIRONMENT,
"API_URL": API_URL,
"WEB_URL": WEB_URL,
"CALLBACK_URL": CALLBACK_URL,
"supabase_url": supabase_url,
"CALLBACK_URL": CALLBACK_URL
}


Expand Down

0 comments on commit 178c432

Please sign in to comment.