Skip to content

fix(auth): keep token endpoint on target scheme for insecure targets#103

Merged
leoparente merged 1 commit into
developfrom
fix/auth-endpoint-scheme-insecure-target
Jul 21, 2026
Merged

fix(auth): keep token endpoint on target scheme for insecure targets#103
leoparente merged 1 commit into
developfrom
fix/auth-endpoint-scheme-insecure-target

Conversation

@leoparente

@leoparente leoparente commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #101

Problem

With an insecure grpc:// (or http://) target, setting DIODE_SKIP_TLS_VERIFY
forced the OAuth token request onto https://, causing SSL: WRONG_VERSION_NUMBER
against a plain-HTTP server.

Cause

_get_full_auth_url() chose the scheme from tls_verify or skip_tls_env. That heuristic
was added (#76) to keep a grpcs:// target on HTTPS when verification is disabled, because
parse_target() had already reduced the scheme to a boolean tls_verify (#62 folded
DIODE_SKIP_TLS_VERIFY into it). But skip_tls_env is only a proxy for "scheme was https",
so an insecure grpc:// target plus the env var was wrongly bumped to HTTPS.

Fix

Track the target's secure/insecure scheme separately (_secure) and build the auth URL from
it. DIODE_SKIP_TLS_VERIFY now only disables certificate verification, never picks the scheme.
This preserves the grpcs:// + skip-verify case the old heuristic was protecting.

Target DIODE_SKIP_TLS_VERIFY Before After
grpc:// unset http http
grpc:// true https (bug) http
grpcs:// unset https https
grpcs:// true https (verify off) https (verify off), preserved

Behavior change

grpc:// / http:// targets with DIODE_SKIP_TLS_VERIFY set now emit an http:// auth URL
instead of https://. DIODE_SKIP_TLS_VERIFY is now strictly a certificate-verification
control, not a scheme selector.

Tests

Strengthened test_auth_url_scheme_follows_target to parametrize secure and tls_verify
independently (mutation-verified: a scheme = self._tls_verify regression fails the new rows,
including grpcs:// + skip). Added a client-level test asserting DiodeClient._secure follows
the target scheme even with the env var set. Full suite: 127 passed.

Note: skip_tls_verify=True was never a DiodeClient argument, so that TypeError from the
report is expected.

Out of scope (separate follow-up)

Pre-existing and untouched here: for grpcs:// + DIODE_SKIP_TLS_VERIFY, the gRPC ingest/OTLP
data channels key off the same tls_verify boolean and build a plaintext insecure_channel
against a TLS server, so skip-verify downgrades the transport instead of just relaxing cert
verification. Worth a separate issue.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

Coverage

Coverage Report
FileStmtsMissCoverMissing
/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/netboxlabs/diode/sdk
   chunking.py33197%112
   client.py5674293%202–203, 222–224, 227–230, 522, 590, 595, 599, 682–687, 732–734, 764, 768, 772, 794, 815, 817, 891, 922, 930, 992–993, 1002, 1035, 1062, 1067–1068, 1097, 1102–1105
   exceptions.py44393%69, 82–83
TOTAL6594693% 

Tests Skipped Failures Errors Time
213 0 💤 0 ❌ 0 🔥 2.578s ⏱️

@leoparente
leoparente marked this pull request as draft July 21, 2026 16:45
@leoparente

Copy link
Copy Markdown
Contributor Author

@codex review

@davidlanouette davidlanouette left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 questions, but generally looks good.

Comment thread tests/test_client.py Outdated
Comment thread tests/test_client.py
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: cb6a89b964

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The auth token URL scheme was derived from tls_verify plus
DIODE_SKIP_TLS_VERIFY, which forced HTTPS for an insecure grpc:// (or
http://) target whenever DIODE_SKIP_TLS_VERIFY was set, producing an
SSL WRONG_VERSION_NUMBER against a plain-HTTP server.

Track the target's secure/insecure scheme separately and build the auth
URL from it. DIODE_SKIP_TLS_VERIFY now only controls certificate
verification, never http vs https.

Fixes #101

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@leoparente
leoparente force-pushed the fix/auth-endpoint-scheme-insecure-target branch from cb6a89b to d549c0f Compare July 21, 2026 16:56
@leoparente leoparente self-assigned this Jul 21, 2026
@leoparente
leoparente marked this pull request as ready for review July 21, 2026 18:03
@leoparente
leoparente merged commit 8dabcd1 into develop Jul 21, 2026
6 checks passed
@leoparente
leoparente deleted the fix/auth-endpoint-scheme-insecure-target branch July 21, 2026 18:04
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.13.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DiodeClient forces HTTPS for token endpoint when target uses grpc:// (plain HTTP)

2 participants