[PR #7228] feat(oauth-provider): database hooks #7160

Open
opened 2026-03-13 13:26:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7228
Author: @dvanmali
Created: 1/9/2026
Status: 🔄 Open

Base: canaryHead: opHooks


📝 Commits (4)

  • cce4300 feat: OAuth Client and Consent db hooks
  • ac795fd docs: lifecycle hook features
  • de735e4 fix: cubic-dev suggestions
  • 6bf0e1b feat: separate data and override return types

📊 Changes

6 files changed (+308 additions, -25 deletions)

View changed files

📝 docs/content/docs/plugins/oauth-provider.mdx (+112 -0)
📝 packages/oauth-provider/src/consent.ts (+38 -20)
📝 packages/oauth-provider/src/oauthClient/endpoints.ts (+24 -3)
📝 packages/oauth-provider/src/oauthConsent/endpoints.ts (+7 -1)
📝 packages/oauth-provider/src/register.ts (+15 -1)
📝 packages/oauth-provider/src/types/index.ts (+112 -0)

📄 Description

Add lifecycle hooks for OAuthClient and OAuthConsent tables similar to the structure of the organization plugin.


Summary by cubic

Adds database lifecycle hooks to the OAuth provider for OAuthClient and OAuthConsent operations. This enables validation, auditing, and metadata changes around create, update, and delete.

  • New Features
    • New databaseHooks option with before/after hooks for client and consent create/update/delete.
    • Client create/update hooks can return { data } to add fields or { overrides } to replace persisted values.
    • Endpoints call hooks around adapter operations to enforce rules or log events.
    • Docs updated with usage examples.

Written for commit 6bf0e1b0e9. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7228 **Author:** [@dvanmali](https://github.com/dvanmali) **Created:** 1/9/2026 **Status:** 🔄 Open **Base:** `canary` ← **Head:** `opHooks` --- ### 📝 Commits (4) - [`cce4300`](https://github.com/better-auth/better-auth/commit/cce43008f28441af0b4f28b293d4db3cbfca8a12) feat: OAuth Client and Consent db hooks - [`ac795fd`](https://github.com/better-auth/better-auth/commit/ac795fd8c8c958d32640f695bc45154b655a630f) docs: lifecycle hook features - [`de735e4`](https://github.com/better-auth/better-auth/commit/de735e41263e718ec41bd1bd4f29c2bd4e9b4523) fix: cubic-dev suggestions - [`6bf0e1b`](https://github.com/better-auth/better-auth/commit/6bf0e1b0e9b048e142d2a9fc0b3decfe2adb6a62) feat: separate data and override return types ### 📊 Changes **6 files changed** (+308 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/oauth-provider.mdx` (+112 -0) 📝 `packages/oauth-provider/src/consent.ts` (+38 -20) 📝 `packages/oauth-provider/src/oauthClient/endpoints.ts` (+24 -3) 📝 `packages/oauth-provider/src/oauthConsent/endpoints.ts` (+7 -1) 📝 `packages/oauth-provider/src/register.ts` (+15 -1) 📝 `packages/oauth-provider/src/types/index.ts` (+112 -0) </details> ### 📄 Description Add lifecycle hooks for `OAuthClient` and `OAuthConsent` tables similar to the structure of the [organization plugin](https://www.better-auth.com/docs/plugins/organization#organization-hooks). <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds database lifecycle hooks to the OAuth provider for OAuthClient and OAuthConsent operations. This enables validation, auditing, and metadata changes around create, update, and delete. - **New Features** - New databaseHooks option with before/after hooks for client and consent create/update/delete. - Client create/update hooks can return { data } to add fields or { overrides } to replace persisted values. - Endpoints call hooks around adapter operations to enforce rules or log events. - Docs updated with usage examples. <sup>Written for commit 6bf0e1b0e9b048e142d2a9fc0b3decfe2adb6a62. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:26:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7160