Skip to content

Feat/har capture and logger improvements#301

Merged
moshloop merged 2 commits intomasterfrom
feat/har-capture-and-logger-improvements
Mar 17, 2026
Merged

Feat/har capture and logger improvements#301
moshloop merged 2 commits intomasterfrom
feat/har-capture-and-logger-improvements

Conversation

@moshloop
Copy link
Member

@moshloop moshloop commented Mar 17, 2026

Summary by CodeRabbit

  • New Features

    • Added native HTTP Digest authentication support for secure API communication and credential handling.
  • Bug Fixes

    • Enhanced error response logging by capturing full response body details for HTTP error status codes (400 and above).
  • Tests

    • Added comprehensive test coverage for HTTP Digest authentication, including successful authentication and failure scenarios.

… implementation

Removes external dependency on Snawoot/go-http-digest-auth-client and implements digest authentication directly in the codebase. This provides better control over the implementation and eliminates an unnecessary external dependency while maintaining compatibility with digest auth endpoints.
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8b6f9688-2c6c-4694-bd8c-034ce55d077f

📥 Commits

Reviewing files that changed from the base of the PR and between acb62da and 84379a1.

⛔ Files ignored due to path filters (2)
  • cmd/hx/go.sum is excluded by !**/*.sum
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • cmd/hx/fixtures/hx.md
  • cmd/hx/go.mod
  • go.mod
  • har/middleware.go
  • http/client.go
  • http/digest.go
  • http/digest_test.go

Walkthrough

This PR replaces an external digest authentication dependency with an internal HTTP Digest Authentication implementation. The custom digest transport handles authentication challenges, computes authorization headers per RFC specifications, and retries requests. Dependencies are updated accordingly, and comprehensive tests validate the implementation.

Changes

Cohort / File(s) Summary
HTTP Digest Authentication Implementation
http/digest.go, http/digest_test.go
Introduces digestTransport with two-phase request flow: initial request, 401 challenge handling, and authenticated retry. Includes WWW-Authenticate parsing, digest auth computation (MD5, SHA-256 with session variants), body handling for replay, and comprehensive unit tests covering transport flow, auth caching, header parsing, and string formatting.
Digest Auth Integration
http/client.go
Replaces external digest transport constructor (dac.NewDigestTransport) with internal newDigestTransport function for Digest authentication initialization.
Dependency Management
go.mod, cmd/hx/go.mod
Removes github.com/Snawoot/go-http-digest-auth-client dependency (v1.1.3). Adds github.com/stretchr/testify v1.11.1 as direct dependency with related indirect transitive dependencies. Updates github.com/flanksource/is-healthy from v1.0.84 to v1.0.85.
Test Fixtures & Response Handling
cmd/hx/fixtures/hx.md, har/middleware.go
Adds two Digest authentication test cases (successful and wrong password scenarios). Modifies response body capture in buildResponse to trigger for HTTP status codes 400 and above, extending error response handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant digestTransport
    participant Server
    participant RequestHandler

    Client->>digestTransport: RoundTrip(request)
    digestTransport->>digestTransport: Clone request, preserve body
    digestTransport->>Server: First request (no auth header)
    Server-->>digestTransport: 401 Unauthorized + WWW-Authenticate
    digestTransport->>digestTransport: parseWWWAuthenticate()
    digestTransport->>digestTransport: computeDigestAuth(credentials, challenge)
    digestTransport->>digestTransport: setDigestHeader(Authorization header)
    digestTransport->>digestTransport: Replay original body via GetBody()
    digestTransport->>Server: Second request (with Authorization header)
    Server-->>digestTransport: 200 OK (or final response)
    digestTransport-->>Client: Return response
Loading

Suggested labels

dependencies

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/har-capture-and-logger-improvements
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@moshloop moshloop merged commit ab847d5 into master Mar 17, 2026
5 checks passed
@moshloop moshloop deleted the feat/har-capture-and-logger-improvements branch March 17, 2026 07:49
@github-actions
Copy link

🎉 This PR is included in version 1.48.2 🎉

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant