Files
Tom Moor 957648a588 feat: OAuth dynamic client registration (#11462)
* feat: DCR first pass

* Add cleanup task, management endpoints

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* wip

* Combine migrations

* Self review

* fix: Guard OAuth policies

* fix: Application access list not updating on deletion

* feat: Add OAUTH_DISABLE_DCR env var to disable dynamic client registration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: Validate max length of redirect URIs in DCR schemas

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Self review

* Use withCtx methods for correct event creation

* Remove incorrect scopes_supported

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 17:30:19 -05:00

27 lines
694 B
TypeScript

import type { Next } from "koa";
import type { AppContext } from "@server/types";
/**
* Middleware that defines the `ctx.context` getter, which provides the current
* request's auth, transaction, and IP to database mutation helpers like
* `saveWithCtx` and `destroyWithCtx`.
*
* @returns The middleware function.
*/
export function apiContext() {
return async function apiContextMiddleware(ctx: AppContext, next: Next) {
Object.defineProperty(ctx, "context", {
configurable: true,
get() {
return {
auth: ctx.state.auth,
transaction: ctx.state.transaction,
ip: ctx.request.ip,
};
},
});
return next();
};
}