Skip to content

Commit

Permalink
Merge pull request #37 from p1utoze/local
Browse files Browse the repository at this point in the history
update: HTML file headers and GoogleSSO config
  • Loading branch information
p1utoze authored Dec 2, 2023
2 parents 1c39965 + 4c6a0d0 commit dd34e40
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ name: Trigger auto deployment for hackme-azure
on:
# Automatically trigger it when detected changes in repo
push:
branches:
branches:
[ main ]
paths:
- '**'
- '.github/workflows/hackme-azure-AutoDeployTrigger-a5080cd7-d05e-4d70-af7d-0fde22df3a4c.yml'

# Allow manual trigger
# Allow manual trigger
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
Expand All @@ -29,14 +29,10 @@ jobs:
- name: Build and push container image to registry
uses: azure/container-apps-deploy-action@v2
with:
appSourcePath: ${{ github.workspace }}
appSourcePath: ${{ github.workspace }}
registryUrl: docker.io
registryUsername: ${{ secrets.HACKMEAZURE_REGISTRY_USERNAME }}
registryPassword: ${{ secrets.HACKMEAZURE_REGISTRY_PASSWORD }}
containerAppName: hackme-azure
resourceGroup: MyProjects
imageToBuild: p1utoze/hackme-azure:${{ github.sha }}




22 changes: 8 additions & 14 deletions app/auth/google_sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@
from fastapi.responses import RedirectResponse
from fastapi_sso.sso.google import GoogleSSO
from starlette.requests import Request
import os
import firebase_admin
from firebase_admin import auth as fb_auth
from app.admin.utils import (
GOOGLE_CLIENT_SECRET,
GOOGLE_CLIENT_ID,
HOST,
COOKIE_NAME,
)


os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" # Only for development
# os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" # Only for development


def get_google_sso() -> GoogleSSO:
return GoogleSSO(
GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET,
f"{HOST}/v1/google/callback",
allow_insecure_http=True, # Disable this in production
# redirect_uri=f"{HOST}/v1/google/callback", # For development
)


router = APIRouter(prefix="/v1/google")


@router.get("/login", tags=["Google SSO"])
async def auth_init(sso=Depends(get_google_sso)):
async def auth_init(request: Request, sso=Depends(get_google_sso)):
"""Initialize auth and redirect."""
return await sso.get_login_redirect()
return await sso.get_login_redirect(
redirect_uri=request.url_for("auth_callback")
)


@router.get("/callback", response_class=RedirectResponse, tags=["Google SSO"])
Expand All @@ -48,17 +47,12 @@ async def auth_callback(request: Request, sso=Depends(get_google_sso)):
request.url_for("register_participant").path
+ f'?uid={request.cookies.get("userId")}'
)
response = RedirectResponse(
url=redirect_url, status_code=status.HTTP_302_FOUND
)
response = RedirectResponse(url=redirect_url)
else:
response = RedirectResponse(
url=request.url_for("home"), status_code=status.HTTP_302_FOUND
)
response = RedirectResponse(url=request.url_for("home"))
response.set_cookie(
key=COOKIE_NAME,
value=user_id_token.decode(),
httponly=True,
max_age=1800,
)
return response
Expand Down
4 changes: 2 additions & 2 deletions app/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<link rel="stylesheet" type="text/css" href="{{ url_for('static', path='css/dashboard.css') }}">
<link rel="stylesheet" type="text/css" href="../static/css/dashboard.css">
<title>Document</title>
</head>
<body>
Expand Down Expand Up @@ -54,4 +54,4 @@ <h3>Team Name: {{ team_name }}</h3>
{% endif %}
</div>
</body>
</html>
</html>
10 changes: 3 additions & 7 deletions app/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="{{ url_for('static', path='css/login.css') }}">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<link rel="stylesheet" href="../static/css/login.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
{% if redirect==True %}
<meta http-equiv = "refresh" content = "0; url = {{ base_url }}" />
{% else %}
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
{% endif %}
<title>Login</title>
</head>
<body>
Expand Down
7 changes: 5 additions & 2 deletions app/templates/master_checkin.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<link rel="stylesheet" href="../static/css/master_checkin.css">
<title>Admin Registration - Hackathon</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', path='css/master_checkin.css') }}">
</head>
<body>
<div class="header">
Expand Down
3 changes: 1 addition & 2 deletions app/templates/registration_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width= , initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<title>REGISTRATION</title>
</head>
<body style="background-color:{{ status }}">
Expand Down
9 changes: 5 additions & 4 deletions app/templates/update_status.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>User Status - Hackathon</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', path='css/update_status.css') }}">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<link rel="stylesheet" href="../static/css/update_status.css">
</head>
<body>
<div class="header">
Expand Down

0 comments on commit dd34e40

Please sign in to comment.