-
Notifications
You must be signed in to change notification settings - Fork 12
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: add authentication configs (TCTC-9914) #1842
base: master
Are you sure you want to change the base?
Conversation
|
||
Call refresh token route if the access token has expired. | ||
""" | ||
oauth_token_info = self._secrets_keeper.load(self.auth_flow_id) |
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.
model pydantic
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.
Looks good to me, thanks for the hard work 👍
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.
Nice work, gg 🏅 A few remarks but nothing blocking. Also, could you please add all files in toucan_connectors/http_api
to the list of files checked by mypy in pyproject.toml
?
if isinstance(token_response["expires_at"], str): | ||
expires_at = None | ||
for date_format in _SUPPORTED_EXPIRATION_FORMATS: | ||
try: | ||
expires_at = datetime.strptime(token_response["expires_at"], date_format) | ||
break | ||
except ValueError: | ||
continue | ||
if expires_at is not None: | ||
return expires_at | ||
raise ValueError(f"Can't parse the oauth2 token expiration: {token_response['expires_at']}") | ||
return datetime.fromtimestamp(int(token_response["expires_at"])) |
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.
could we maybe use a pydanti validator for that ? It would handle key errors, type errors etc
raise ValueError(f"Can't parse the oauth2 token expiration: {token_response['expires_at']}") | ||
return datetime.fromtimestamp(int(token_response["expires_at"])) | ||
else: | ||
return datetime.now() + timedelta(0, int(token_response.get("expires_in", default_lifetime))) |
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.
note: dateutil
's timedelta
is smarter. Also, you you please use kwargs for the timedelta ?
|
||
:param workflow_callback_context: the context which will be passed to the workflow token saver callback | ||
""" | ||
pass |
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.
pass |
can be omitted when there's a docstring
authorization_response: str, | ||
): | ||
"""Retrieve authorization token from oauth2 backend""" | ||
pass |
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.
pass |
raise MissingOauthWorkflowError() | ||
|
||
# Verify the oauth2 workflow token | ||
assert workflow_token == JsonWrapper.loads(url_params["state"][0])["workflow_token"] |
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.
same here, could we use pydantic to load the params ? They're user-provided input so it could be anything
Implements new
authentication
configuration onHTTP API
connectorsEverything is described in the PAT : https://toucantoco.atlassian.net/wiki/spaces/TTA/pages/4645355521/PAT+278+--+HTTP+connector+oAuth2+management