← Back to Pull requests

feat(auth): resolve OAuth server clients from application storage #270

Open
unknown opened this pull request with 405 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 25, 2026 13:02 UTC
Author

OAuthServer.make and makeOpenId only know clients from the static clients option and Client ID Metadata Documents. An application that registers clients itself, for example through its own RFC 7591 endpoint, cannot serve them, and confidential clients need a plaintext clientSecret.

Each server now exposes an optional oauth.Clients service, consulted after static clients and before metadata discovery. Client gains clientSecretDigest, the unpadded base64url SHA-256 of a generated secret, so stored rows never hold plaintext.

const oauth = OAuthServer.makeOpenId("identity");

const ClientsLive = Layer.effect(
  oauth.Clients,
  Effect.gen(function* () {
    const registrations = yield* Registrations;

    return oauth.Clients.of({ get: (clientId) => registrations.find(clientId) });
  }),
);

  • Lookups are not cached, so secret rotation and deletion apply to the next request.

  • Rows decode as Client. Rows the server cannot use (unknown keys, failed decode, a plaintext clientSecret) are reported and return 503, like other application service output. A row for another ID or with a jwksUri is invalid_client: stored private_key_jwt clients use inline jwks, so registrant-chosen hosts cannot hold the shared discovery permits.

  • Stored callbacks may be self-registered, so trust now comes from where the client was resolved instead of config.clients.some(...). Stored clients get the confirmation page instead of direct error redirects, and prompt=none is refused (RFC 9700 section 4.11.2). This also keeps new URL(clientId) away from non-URL IDs in the error redirect and consent page.
  • Out of scope: a registration endpoint, per-client allowed scopes, and client_credentials.

    <!-- codesmith:footer -->
    ---
    <a href="https://app.blacksmith.sh/yielded-dev/codesmith/auth/pr/270?autoLogin=true&ref=codesmith_pr_footer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v3.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png" width="162" height="28"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1795525376&installation_model_id=440452&pr_number=270&ref=codesmith_pr_footer&repository=yielded-dev%2Fauth&return_to=https%3A%2F%2Fgithub.com%2Fyielded-dev%2Fauth%2Fpull%2F270&signature=bec3367fe4cc8b06ccd825de9e3e370b2e0c7763fa5d4ee33359fe1d61346a5f"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png" width="190" height="28"></picture></a>
    <sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup>

    <!-- codesmith:autofix:disabled -->
    <!-- /codesmith:footer -->

    Diff: 405 lines (+303 / -102) across 5 files Reviewer: github-actions[bot] Review duration: 6m
    All Vouch review confidence checks passed
    Residual risk 0.45 = Change Risk (0.68) × (1 − Review Confidence (0.34)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.68 · 405 lines diff across 5 files
    0.68
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 60% · Reviewer familiarity: 35%
    34%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.359
    Shallow Review Depth shallow_review_depth
    0.344
    Sensitive Paths sensitive_paths
    0.068
    Real PR Conversation Timeline
    1 comments
    "Review active on #270"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 34.2% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 68.0% (HIGH) · Higher = larger blast radius
    68.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 34.2% · Lower = rushed or shallow review
    34.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 44.7% · Moderate risk
    44.7%