Skip to content

Commit

Permalink
Merge branch 'subsetter_argo' into subsetter_front_clean
Browse files Browse the repository at this point in the history
  • Loading branch information
devincowan committed Nov 15, 2023
2 parents 8a0957e + a78fc49 commit a0008ba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 3 additions & 5 deletions app/api/subsetter/app/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from beanie import PydanticObjectId
from fastapi import Depends, Request
from fastapi_users import BaseUserManager, FastAPIUsers
from fastapi_users.authentication import AuthenticationBackend, JWTStrategy, CookieTransport, BearerTransport
from fastapi_users.authentication import AuthenticationBackend, BearerTransport, CookieTransport, JWTStrategy
from fastapi_users.db import BeanieUserDatabase, ObjectIDIDMixin
from httpx_oauth.oauth2 import OAuth2, GetAccessTokenError, OAuth2Token
from httpx_oauth.errors import GetIdEmailError
from httpx_oauth.oauth2 import OAuth2, GetAccessTokenError, OAuth2Token
from subsetter.app.db import User, get_user_db

SECRET = "SECRET"
Expand All @@ -32,9 +32,7 @@ async def get_id_email(self, token: str) -> Tuple[str, str]:

class FrontOAuth2(CUAHSIOAuth2):
# https://github.com/frankie567/httpx-oauth/blob/v0.13.0/httpx_oauth/oauth2.py#L131
async def get_access_token(
self, code: str, redirect_uri: str, code_verifier: Optional[str] = None
):
async def get_access_token(self, code: str, redirect_uri: str, code_verifier: Optional[str] = None):
async with self.get_httpx_client() as client:
data = {
"grant_type": "authorization_code",
Expand Down
1 change: 1 addition & 0 deletions app/api/subsetter/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Settings(BaseSettings):
oauth2_client_id: str
oauth2_client_secret: str
oauth2_redirect_url: str
oauth2_cookie_redirect_url: str

minio_access_key: str
minio_secret_key: str
Expand Down
25 changes: 20 additions & 5 deletions app/api/subsetter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
# https://swagger.io/docs/specification/api-host-and-base-path/
# https://fastapi.tiangolo.com/how-to/configure-swagger-ui/
# https://github.com/tiangolo/fastapi/pull/499
swagger_params = {"withCredentials": True,
"oauth2RedirectUrl": front_oauth_client.authorize_endpoint,
"swagger_ui_client_id": front_oauth_client.client_id}
swagger_params = {
"withCredentials": True,
"oauth2RedirectUrl": front_oauth_client.authorize_endpoint,
"swagger_ui_client_id": front_oauth_client.client_id,
}

app = FastAPI(servers=[{"url": os.environ['VITE_APP_API_URL']}], swagger_ui_parameters=swagger_params)

Expand Down Expand Up @@ -62,7 +64,12 @@
)

app.include_router(
fastapi_users.get_oauth_router(front_oauth_client, cookie_backend, SECRET),
fastapi_users.get_oauth_router(
front_oauth_client,
cookie_backend,
SECRET,
redirect_url=get_settings().oauth2_cookie_redirect_url
),
prefix="/auth/cookie",
tags=["auth"],
)
Expand All @@ -82,7 +89,15 @@ async def on_startup():
User,
],
)
arguments = ['mc', 'alias', 'set', 'cuahsi', f"https://{get_settings().minio_api_url}", get_settings().minio_access_key, get_settings().minio_secret_key]
arguments = [
'mc',
'alias',
'set',
'cuahsi',
f"https://{get_settings().minio_api_url}",
get_settings().minio_access_key,
get_settings().minio_secret_key,
]
try:
_output = subprocess.check_output(arguments)
except subprocess.CalledProcessError as e:
Expand Down

0 comments on commit a0008ba

Please sign in to comment.