-
Notifications
You must be signed in to change notification settings - Fork 241
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
feat: pass api_access_token to executor client #1473
Conversation
querybook/server/app/auth/utils.py
Outdated
@@ -19,8 +19,13 @@ class AuthenticationError(Exception): | |||
|
|||
|
|||
class AuthUser(UserMixin): | |||
def __init__(self, user: User): | |||
def __init__(self, user: User, api_access_token=False): |
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.
api_access_token is a boolean flag?
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.
consider renaming it to something more clear
api_access_token = ( | ||
True if request.headers.get("api-access-token", None) else False | ||
) | ||
metadata = metadata or {} | ||
metadata["api_access_token"] = api_access_token | ||
logic.create_query_execution_metadata( | ||
query_execution.id, metadata, session=session | ||
) |
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.
metadata = {}
used_api_token = request.headers.get("api-access-token", None) is not None
if used_api_token:
metadata["used_api_token"] = used_api_token
if metadata:
logic.create(...)
@@ -528,6 +528,16 @@ def __init__( | |||
self._client = None | |||
self._cursor = None | |||
|
|||
with DBSession() as session: |
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.
dbsession is not needed if you are only calling once
@@ -528,6 +528,16 @@ def __init__( | |||
self._client = None | |||
self._cursor = None | |||
|
|||
with DBSession() as session: | |||
query_execution_metadata = ( |
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.
this might be None? (if metadata wasn't created)
self._query_execution_id, session=session | ||
).execution_metadata | ||
) | ||
self._api_access_token = query_execution_metadata.get( |
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.
rename to used_api_token or some other boolean name
api_access_token was used as a str to represent the actual token, let's not reuse the same name for a boolean flag?
If we use
api-access-token
in request header, then pass it down to the executor clientThen in Presto client, we can use this flag to determine whether to continue using ldap auth or pass outh jwt instead.