Skip to content

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
Contributor

@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
@ponyisi ponyisi deleted the bearer-token-noexp branch October 18, 2025 17:23
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