Skip to content

[log] Add debug logging to server/middleware_auth.go#9087

Merged
lpcox merged 2 commits into
mainfrom
log/middleware-auth-logging-ec1ee93415f98bcb
Jul 11, 2026
Merged

[log] Add debug logging to server/middleware_auth.go#9087
lpcox merged 2 commits into
mainfrom
log/middleware-auth-logging-ec1ee93415f98bcb

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Adds 3 meaningful debug logging calls to internal/server/middleware_auth.go to improve troubleshooting of authentication middleware.

Changes

File: internal/server/middleware_auth.go

  • applyIfConfigured: Log when auth middleware is applied (key configured) vs. skipped (no key configured)
  • rejectAuthRequest: Log rejection details including HTTP status, error code, failure reason, request path, and remote address

Why these logs are useful

  • Middleware setup visibility: Makes it clear during debug whether auth is enabled, which is key for diagnosing 401 vs. unauthenticated access issues
  • Request rejection context: When a request fails auth, the log captures status code, error code, detail, path, and remote address in one place — no need to cross-reference multiple log sources

Validation

  • go build ./internal/server/...
  • go test ./internal/server/...
  • go vet ./internal/server/...

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Go Logger Enhancement · 370.2 AIC · ⊞ 7.6K ·

Add meaningful debug log calls to authentication middleware:
- Log when auth key is configured vs. not configured in applyIfConfigured
- Log auth rejection details (status, code, detail, path, remote) in rejectAuthRequest

These logs help troubleshoot authentication issues by making it visible when
middleware is applied and providing context on why requests are rejected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Jul 10, 2026
@lpcox lpcox marked this pull request as ready for review July 11, 2026 12:41
Copilot AI review requested due to automatic review settings July 11, 2026 12:41

Copilot AI 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.

Pull request overview

Adds debug visibility for authentication middleware setup and rejected requests.

Changes:

  • Logs whether middleware configuration is applied or skipped.
  • Logs authentication rejection context.
Show a summary per file
File Description
internal/server/middleware_auth.go Adds authentication setup and rejection diagnostics.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread internal/server/middleware_auth.go Outdated
// If key is empty the handler is returned unchanged.
func applyIfConfigured(key string, handler http.HandlerFunc, middleware func(string, http.HandlerFunc) http.HandlerFunc) http.HandlerFunc {
if key != "" {
logAuth.Print("Auth key configured, applying middleware")
@lpcox

lpcox commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

Copilot AI commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in commit d725a9f. I moved setup logging out of the shared applyIfConfigured helper and into applyAuthIfConfigured/applyHMACIfConfigured, so auth and HMAC now log component-specific configuration messages without contradiction.

Copilot finished work on behalf of lpcox July 11, 2026 12:52
Copilot AI requested a review from lpcox July 11, 2026 12:52
@lpcox lpcox merged commit 935415f into main Jul 11, 2026
23 checks passed
@lpcox lpcox deleted the log/middleware-auth-logging-ec1ee93415f98bcb branch July 11, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants