Skip to content

feat: auth bearer token management (issue #110) - #118

Open
jennifer-bowser wants to merge 9 commits into
mainfrom
issue-110-auth-token-mgmt
Open

jennifer-bowser wants to merge 9 commits into
mainfrom
issue-110-auth-token-mgmt

Conversation

@jennifer-bowser

@jennifer-bowser jennifer-bowser commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #110

@jennifer-bowser jennifer-bowser self-assigned this Oct 26, 2026
@jennifer-bowser jennifer-bowser added the priority:medium Medium priority label Oct 26, 2026
Comment thread src/anyvlm/main.py
@jennifer-bowser jennifer-bowser added the priority:high High priority label Oct 27, 2026
@jennifer-bowser
jennifer-bowser marked this pull request as ready for review October 27, 2026 20:23
@jennifer-bowser
jennifer-bowser requested a review from a team as a code owner October 27, 2026 20:23
@jennifer-bowser jennifer-bowser removed the priority:medium Medium priority label Oct 27, 2026

@korikuzma korikuzma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a quick review from Codex. I haven’t reviewed the PR myself yet, but I can take a look later this week.

Please address token expiry and blocking I/O, add outbound authentication tests, and document the new client.

Comment on lines +58 to +60
self._token_expiry = datetime.now(tz=UTC) + timedelta(
seconds=data["expires_in"]
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codex finding: Normal: Refresh tokens before their actual expiration

Adding expires_in after receiving the response extends the cached lifetime by the response delay, allowing expired tokens to be reused and requests to fail authentication. OAuth measures this lifetime from when the response was generated (section 5.1). Calculate expiry conservatively from the request start, include a refresh margin, and test delayed token responses with a controlled clock.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codex finding: Severity - Moderate (incorrect behavior under specific, realistic conditions); Blocking: Finish the conservative expiry calculation

The 30-second refresh margin addresses part of the original comment. Expiry is still calculated after receiving the response: if delivery takes 40 seconds after Auth0 generates the token response, the cached deadline falls 10 seconds after the token’s actual expiration. Requests’ timeout=10 limits socket inactivity, not total response duration (documentation).

Please calculate expiry conservatively, such as by anchoring it immediately before requests.post(), and add the previously requested controlled-clock test for delayed responses. This remains blocking because the current calculation can allow an expired token to be reused, causing outbound authentication failures.

Comment thread src/anyvlm/outbound/vlm_client.py
Comment thread src/anyvlm/outbound/vlm_client.py
Comment thread .env.example
Comment on lines +15 to +16
VLM_CLIENT_ID="example-client-id"
VLM_CLIENT_SECRET="example-client-secret"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codex finding: Minor: Add outbound authentication documentation

These variables appear in the generated example environment page, but users have no setup or client usage instructions. Please document credential setup, the fixed Auth0 endpoint and audience, and a minimal client example under docs/, and include the new modules in the API reference. Clarify that credentials are required for outbound authentication; the existing inbound endpoints do not instantiate this provider.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codex finding: Severity - Moderate (incorrect behavior under specific, realistic conditions); Blocking: Correct the credential setup instructions

Credential setup instructions are now present, but the configuration table names the secret VLM_SECRET_ID; the implementation reads VLM_CLIENT_SECRET. Following the table therefore sends no configured client secret to Auth0 and prevents token retrieval. Please change the documented name to VLM_CLIENT_SECRET.

Please also distinguish these outbound credentials from the settings required to launch the existing inbound service. The table’s introductory note currently says every listed value is required for startup, although the inbound service does not instantiate TokenProvider. These are corrections needed to make the setup instructions accurate, separate from the optional documentation additions in the original comment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codex finding: Severity - Low (limited impact, such as documentation or maintainability issues); Non-blocking: Add client usage guidance

The previously suggested fixed Auth0 endpoint and audience, minimal client example, and API-reference entries are still absent. Adding them would help developers construct and use the outbound client without reading its implementation. These additions are optional and can be left out; they do not need a separate issue.

Comment thread src/anyvlm/outbound/vlm_client.py

@korikuzma korikuzma left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is still Codex reviewing. Kori will perform a human review tomorrow.

Reopened the token-expiry and credential-setup threads because required fixes remain. Please address these before merging. The optional documentation improvements can be left out.

@korikuzma korikuzma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some small human review suggestions that are non-blocking

Comment on lines +27 to +32
* - ``VLM_CLIENT_ID``
- The `client_id` provided to you by the VLM Network administrators
- ``"kjnq3iuyththofdh88347"``
* - ``VLM_SECRET_ID``
- The `client_secret` provided to you by the VLM Network administrators
- ``"nlk34t98nvcnjkcf78r9shvfkidsxhfabn3947tghvdb9"``

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick (nonblocking): could we use placeholders that are more obvious that they're placeholders?

Suggested change
* - ``VLM_CLIENT_ID``
- The `client_id` provided to you by the VLM Network administrators
- ``"kjnq3iuyththofdh88347"``
* - ``VLM_SECRET_ID``
- The `client_secret` provided to you by the VLM Network administrators
- ``"nlk34t98nvcnjkcf78r9shvfkidsxhfabn3947tghvdb9"``
* - ``VLM_CLIENT_ID``
- The `client_id` provided to you by the VLM Network administrators
- ``"example-client-id"``
* - ``VLM_SECRET_ID``
- The `client_secret` provided to you by the VLM Network administrators
- ``"example-client-secret"``

json={
"client_id": os.getenv("VLM_CLIENT_ID"),
"client_secret": os.getenv("VLM_CLIENT_SECRET"),
"audience": self.AUDIENCE_URL,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggestion (non-blocking): We may consider adding a check for these env vars in the init and raise an error if either are missing

)

if response.status_code != HTTPStatus.OK:
error_message: str = "Unable to fetch bearer token from Auth0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggestion (non-blocking): We should consider adding the status code to the error message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high High priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build auth bearer token management

2 participants