Skip to content

refactor(sts): consolidate exchange logging into one outcome log - #16

Merged
arber-salihi merged 2 commits into
mainfrom
log-improvements
May 26, 2026
Merged

refactor(sts): consolidate exchange logging into one outcome log#16
arber-salihi merged 2 commits into
mainfrom
log-improvements

Conversation

@hibare

@hibare hibare commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Consolidate exchange logging into a single deferred Service.logExchange that emits one structured line per request — INFO on success, WARN on denial, ERROR on internal failures — with full caller, policy, and token context on every path.

Changes

  • Replace per-layer authorizer logs and per-step INFO breadcrumbs with one outcome log on Service.Exchange. Reads only from the response and *ExchangeError; no progress state inside Exchange.
  • Authorizer drops its logger field, logResult method, and *slog.Logger constructor arg — it's now a pure decision engine.
  • ExchangeResponse gains ClientID, TokenHash, TTL tagged json:"-" (consistent with existing Issuer/Subject) so internal observers read full context without affecting API consumers.
  • DEBUG-level oidc validated and github app selected breadcrumbs kept for triage.

Example output

Granted

INFO token exchange granted request_id=abc repository=owner/repo issuer=... subject=... policy=default client_id=Iv1.xxx token_hash=... ttl=900 expires_at=... permissions_count=2

Denied

WARN token exchange denied request_id=abc repository=owner/repo issuer=... subject=... code=POLICY_NOT_FOUND message="no matching policy" details=...

Internal failure

ERROR token exchange denied request_id=abc code=INTERNAL_ERROR message="Audit log failed" details=...

@hibare
hibare force-pushed the log-improvements branch from 1785d54 to fcef338 Compare May 25, 2026 15:40
@hibare
hibare marked this pull request as ready for review May 25, 2026 15:44

@arber-salihi arber-salihi 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.

Looks good to me.

@arber-salihi
arber-salihi merged commit d6557f1 into main May 26, 2026
2 checks passed
@arber-salihi
arber-salihi deleted the log-improvements branch May 26, 2026 11:29
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.

2 participants