Skip to content

Commit

Permalink
skip auth config added
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertSnows committed Sep 6, 2024
1 parent 69cf3af commit 53de9cc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions gen3userdatalibrary/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from fastapi import APIRouter, Depends, HTTPException, Request
from gen3authz.client.arborist.errors import ArboristError
from fastapi.responses import JSONResponse
from jsonschema.exceptions import ValidationError
from pydantic import BaseModel
from sqlalchemy.exc import IntegrityError
Expand Down Expand Up @@ -121,7 +120,21 @@ async def create_user_list(
"""
user_id = await get_user_id(request=request)

# TODO dynamically create user policy
# TODO dynamically create user policy, ROUGH UNTESTED VERSION: need to verify
if not config.DEBUG_SKIP_AUTH:
# make sure the user exists in Arborist
# IMPORTANT: This is using the user's unique subject ID
request.app.state.arborist_client.create_user_if_not_exist(user_id)

resource = f"/users/{user_id}/user-data-library"

try:
logging.debug("attempting to update arborist resource: {}".format(resource))
request.app.state.arborist_client.update_resource("/", resource, merge=True)
except ArboristError as e:
logging.error(e)
# keep going; maybe just some conflicts from things existing already
# TODO: Unsure if this is safe, we might need to actually error here?

await authorize_request(
request=request,
Expand Down

0 comments on commit 53de9cc

Please sign in to comment.