Changelog
Notable changes to rn-forge-fastapi, newest first, in the
Keep a Changelog format.
[Unreleased]
[0.5.2] - 2026-11-20
Changed
- The
testingextra requiresassertpy>=2.36.0.
[0.5.1] - 2026-11-19
Added
- Typed application state:
app_stateandstate_lifespandeclare an application's resources as a class and inject them into routes throughDepends.
[0.5.0] - 2026-11-17
Changed
-
The
rn-forge-commonsrequirement admits 0.10 (<0.11). -
The
rn-forge-authrequirement is>=0.2.0,<0.3; login admission and principal projection come from 0.2. -
Login admission, transaction-cookie parsing and JSON login fields now come from
rn-forge-auth, with no behaviour change. -
Bearer/session principal projection, persisted records and fixed-window arithmetic now come from
rn-forge-auth, with no behaviour change. -
CSV export streams 1,000 rows per chunk, with the same bytes; 100,000 rows take under a second instead of 12 s.
-
batch_create_routerparses the body, validates each item and builds the response once, in worker threads, with unchanged responses, error problems and OpenAPI schema.
Removed
TRANSACTION_COOKIEis no longer exported from the package; import it fromrn_forge.auth.
Fixed
idempotentno longer reads or parses a safe request's body. Malformed JSON on an unsafe method now returns a 400 problem with detail "Request body is not valid JSON", instead of a 422 validation-error problem.
[0.4.1] - 2026-11-13
Added
rn_forge.fastapi.sse.sse_response, behind the newsseextra (sse-starlette): streams an async iterable ofServerSentEventas anEventSourceResponsewith a leadingretryframe and a heartbeat. Anidoreventcontaining a line break or NUL is rejected, and one terminalerrorframe carries the problem when the iterable raises;log=receives each 5xx.log_server_errors: anAppConfig.logsink that logs each 5xx problem atERRORwith the original traceback.
Fixed
- Declares
rn-forge-commonsas a dependency, since it importsrn_forge.commons.logging.
[0.4.0] - 2026-10-29
Added
- The
/authsurface overrn-forge-auth.auth_router(config, prefix="/auth"), configured byAuthRoutesConfig, returns anAPIRouterservingproviders,login/{provider},callback/{provider},session,logout,logout/all,backchannel-logout/{provider}andlogin/passwordoverLoginFlow, with the responses, error codes and__Host-login-txcookie of the Django binding. The development provider exists only withdebug=True.AuthRoutesConfigraisesValueErrorwithout aproblem_type_base. The stores' synchronous calls and the Authlib providers run in the thread pool. The auth guide describes the setup, configuration defaults and the protocols an application implements. - Login sessions.
SessionMiddleware(sessions=sessions_for(config))resolves the session once per request over aSessionStorebehind the__Host-sessioncookie, extends the 30-minute idle expiry and refreshes the cookie on every request exceptGET /auth/session, and clears a cookie that names no valid session.Sessions.readenforces the 12-hour absolute timeout and deletes a session whose version differs from its account's, whose account is inactive or whosesession_refis revoked.active_session(request)returns the resolved session, andawait rotate_session(request)gives it a new ID after a privilege change. The middleware takesuntouched_paths,login_pathandcsrf_exempt_prefixesfor a router mounted under another prefix. - Synchronizer-token CSRF protection.
SessionMiddlewarechecks an unsafe request that carries the__Host-sessioncookie (live, anonymous or stale), or goes to/auth/login/password, and never back-channel logout; a cookie-less request to an application route is left alone. TheX-XSRF-TOKENheader must equal, in constant time, the token stored for the session, which the readableXSRF-TOKENcookie carries. TheOrigin(orRefererover HTTPS) must be the request's own origin or one oftrusted_origins,Sec-Fetch-Site: cross-siteis rejected, forwarded scheme and host count only from atrusted_proxiespeer, and aBearerAuthorizationheader skips the check. A failure is the403csrf-failedproblem. Tokens live in aCsrfStorekeyed by session ID:InMemoryCsrfStore, andRedisCsrfStore.GET /auth/sessionalways sets the cookie, starting a 10-minute anonymous session when there is no session, so login is protected. Login replaces the session ID and the token, logout starts a new anonymous session, androtate_sessioncarries the token to the new ID. - Rate limits on
/auth/login/password(per client and per submitted username) and the callback routes (per client), with the defaults of the Django binding, set byAuthRoutesConfig'slimiter,password_client_limit,password_account_limitandcallback_client_limit(RateLimit(limit, window), orNonefor no limit). A limited request is thetoo-many-requestsproblem,429withRetry-After.InMemoryRateLimitercounts in a fixed window;RedisRateLimitercounts withINCRandEXPIRE. The client is the connection's peer, or the nearest address inX-Forwarded-Forthat is not a trusted proxy when the peer is intrusted_proxies. - Authentication and authorization dependencies.
current_principal(bearer=None)yields the sessionPrincipal(roles and permissions from the account's authorization context,auth_timeandamrfrom the session) or the bearer one; a request with anAuthorizationheader is authenticated bybeareralone, so an invalid token is a401even with a valid session cookie.requires_permission(authenticate, key, action, action_map=None)enforcesrequirement_for(key, action).PolicyGuard(policy, hides_existence=False)applies aResourcePolicy:scope(principal, action, query)narrows a query of any type, andcheck(principal, action, obj)returns the object or raises403, or404whenhides_existenceis true. - Audit events on the
rn_forge.audit.authchannel, with the names and fields of the Django binding:login.success,login.failure,logout,logout.all,logout.backchannel,account.rejected,account.disabledandrate_limitedfrom the routes, andauthorization.deniedfromrequires,requires_permissionandPolicyGuard. A provisioningAccountResolverrecordsaccount.provisionedwithrn_forge.auth.audit. - The
redisextra, which namesrn-forge-auth[redis]. Outsidedebug,auth_routerandSessionsrefuse in-memory session, transaction, replay, CSRF and rate-limit stores with aRuntimeError; the Redis stores arern_forge.auth.redisand, for CSRF tokens and the rate limiter, thern_forge.fastapi.auth.redismodule, which the package facade does not import. - Tests tag each security control of
rn_forge.auth.conformancewith@pytest.mark.security_control, and fail when a control has no test.
Changed
rn_forge.fastapi.authis a package;bearer_auth,basic_authandrequiresimport from it as before.- Breaking:
bearer_auth()takesaccounts(anAccountResolver) andcontexts(anAuthorizationContextProvider), and optionallyscope_map. It resolves the token's(issuer, subject)withaccounts.lookup, never provisions, and answers401for an unlinked or inactive account. The principal'ssubjectis the account ID; roles, tenant and attributes come from the context, and permissions are the context's limited by the token's scopes. It returns aBearerAuthdependency. - Breaking: depends on
rn-forge-authand importsPrincipal,Requirementand the authenticator contracts from it. Theoidcextra namesrn-forge-auth[oidc]instead ofrn-forge-web[auth]. - The package declares the MIT licence and is published to PyPI.
[0.3.2] - 2026-10-25
Changed
- Requires its rn-forge dependencies by version range from pykit's index (ADR-0004), not by git URL.
[0.3.1] - 2026-10-18
Fixed
FastApiAppturns off FastAPI's native tracing (0.142 and later) unless the application passestelemetry=, soAppConfig(tracing=False)records no server spans.
[0.3.0] - 2026-10-16
Changed
- The
transferextra namesrn-forge-datain place ofrn-forge-commons[excel].
[0.2.0] - 2026-10-05
Added
- Soft delete in AIP-164's shape:
soft_delete_router(DELETE {collection}/{id}answering200with the resource, andPOST {collection}/{id}:undelete), theSoftDeleteStoreprotocol andSoftDeleteState, andshow_deleted_param(), all exported fromrn_forge.fastapi. read_mask_param(model)andmasked(page, mask)for thereadMaskquery parameter.batch_get_routertakes a newread_maskparameter (defaultTrue) and applies the mask.batch_get_router(GET :batchGet) andbatch_update_router(POST :batchUpdate, one JSON Merge Patch and optionalifMatchper item) inrn_forge.fastapi.transfer, with theBatchGetStore,BatchUpdateStoreandCurrentprotocols.batch_update_routertakesrequire_if_matchandcodec.- Route factories in
rn_forge.fastapi.transferthat matchrn-forge-django's transfer mixins:import_router(POST :import),import_template_router(GET :importTemplate),batch_create_router(POST :batchCreate) andbatch_delete_router(POST :batchDelete). Each takes a dependency returning a store (ImportStore,TemplateSource,BatchCreateStore,BatchDeleteStore),max_rowsanddependencies=.tabular_exportapplies the export cap inside an application's own list route.RowsResultgainstotal,read_rowstakesformats=and raisesValueErrorwith the shared unsupported and unreadable file details. A store raisesRowsInvalid(422) orItemsDenied(403) fromrn-forge-webfor a failure only it can find. The factories answer the shared 422s: a missing file, a missing or empty list, and a row cap. The transfer guide shows a complete resource overrn-forge-sqlalchemy'supsertandkeyset. - JSON Merge Patch (RFC 7396) binding:
merge_patch_body()checks theapplication/merge-patch+jsonmedia type (415 withAccept-Patch) and returns the raw body,merge_into(model, current, body)parses it, merges and validates against a pydantic model, andmerge_patch_openapi()declares the request body. Declaremerge_patch_body()beforerequire_if_matchand callcheck_preconditionbeforemerge_into. Anullon a non-nullable field rendersThis field may not be null.
Changed
- Breaking:
order_by_paramdescribesorderByas a comma-separated list of fields and names the sortable fields. It described one field. It returns every term, asparse_order_byinrn-forge-webnow accepts several and rejects a repeated field with 400. read_rowspicks the format from the file extension, and uses the content type only when the file name has none, asrn-forge-djangodoes. A.pdfsent astext/csvis now unsupported.
Fixed
tabular_responsewrites the CSV header row when there are no data rows.
[0.1.0] - 2026-09-27
First release.