-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update instructions for local development #10
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ jobs: | |
poetry install -vv --no-interaction | ||
poetry show -vv | ||
- name: Build docs | ||
run: AUDIT_SERVICE_CONFIG_PATH=src/audit/config-default.yaml poetry run python run.py openapi | ||
run: poetry run python run.py openapi | ||
|
||
- uses: stefanzweifel/[email protected] | ||
with: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,10 @@ def get_app(httpx_client=None) -> FastAPI: | |
get_logger("gen3workflow", log_level=log_level) | ||
|
||
logger.info("Initializing Arborist client") | ||
if config["MOCK_AUTH"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming, Gen3Config would automatically ignore if there is no key There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default is False. Defaults are managed by gen3config. |
||
logger.warning( | ||
"Mock authentication and authorization are enabled! 'MOCK_AUTH' should NOT be enabled in production!" | ||
) | ||
custom_arborist_url = os.environ.get("ARBORIST_URL", config["ARBORIST_URL"]) | ||
if custom_arborist_url: | ||
app.arborist_client = ArboristClient( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
from gen3authz.client.arborist.errors import ArboristError | ||
|
||
from gen3workflow import logger | ||
from gen3workflow.config import config | ||
|
||
|
||
# auto_error=False prevents FastAPI from raising a 403 when the request | ||
|
@@ -29,13 +30,19 @@ def __init__( | |
self.bearer_token = bearer_token | ||
|
||
def get_access_token(self): | ||
if config["MOCK_AUTH"]: | ||
return "123" | ||
|
||
return ( | ||
self.bearer_token.credentials | ||
if self.bearer_token and hasattr(self.bearer_token, "credentials") | ||
else None | ||
) | ||
|
||
async def get_token_claims(self) -> dict: | ||
if config["MOCK_AUTH"]: | ||
return {"sub": 64, "context": {"user": {"name": "mocked-user"}}} | ||
|
||
if not self.bearer_token: | ||
err_msg = "Must provide an access token" | ||
logger.error(err_msg) | ||
|
@@ -64,8 +71,10 @@ async def authorize( | |
resources: list, | ||
throw: bool = True, | ||
) -> bool: | ||
token = self.get_access_token() | ||
if config["MOCK_AUTH"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is perfect! I was attempting to set up something similar locally to test some functionality. With this change, I won’t need to anymore—appreciate it! |
||
return True | ||
|
||
token = self.get_access_token() | ||
try: | ||
authorized = await self.arborist_client.auth_request( | ||
token, "gen3-workflow", method, resources | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ DOCS_URL_PREFIX: /gen3workflow | |
# override the default Arborist URL; ignored if already set as an environment variable | ||
ARBORIST_URL: | ||
|
||
# /!\ only use for development! Allows running gen3workflow locally without Arborist interaction | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Appreciate the warning. |
||
MOCK_AUTH: false | ||
|
||
#################### | ||
# GA4GH TES # | ||
#################### | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When was this implemented, I tried to even go back in the commit history to see this. Couldn't find it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a copy paste from requestor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 Gotcha!