Skip to content

Patch for cases where the bearer token has no expiration #594

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

Closed
wants to merge 2 commits into from

Conversation

ponyisi
Copy link
Collaborator

@ponyisi ponyisi commented May 21, 2025

Code assumed an "exp" field was available in JWT bearer tokens. While this is good practice it is not mandatory. Handle this edge case.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses the edge case where JWT bearer tokens may not include an expiration ("exp") field by introducing a new helper function and updating token expiration checks. Key changes include:

  • Adding a static method _effective_expiration to handle tokens without an exp field.
  • Updating token expiration comparisons in _get_authorization to use the new helper.
  • Modifying the test to use patch.dict for environment variable setup, eliminating the need for manual cleanup.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/test_servicex_adapter.py Replaces manual BEARER_TOKEN_FILE setup/teardown with a patch.dict context manager
servicex/servicex_adapter.py Introduces _effective_expiration to handle missing token expiration and updates usage
Comments suppressed due to low confidence (1)

servicex/servicex_adapter.py:89

  • [nitpick] Consider renaming the parameter 'tok' to 'token' for better clarity, and adding a docstring to explain the function's purpose and behavior.
def _effective_expiration(tok) -> float:

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ponyisi ponyisi closed this May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant