Skip to content

Store an authorization only when its flow finishes - #46

Merged
robertlemke merged 1 commit into
mainfrom
task/flow-start-without-row
Sep 14, 2026
Merged

robertlemke merged 1 commit into
mainfrom
task/flow-start-without-row

Conversation

@robertlemke

Copy link
Copy Markdown
Member

Starting an authorization code flow no longer writes to the database. The data of a flow in progress is kept in the state cache, and the authorization is stored only when the flow finishes. Every browser which opens a page protected by an OAuth or OpenID Connect login, including crawlers, therefore no longer causes a database write and a flush of the entity manager.

Breaking change: metadata can no longer be attached to a flow in progress with setAuthorizationMetadata(), because no authorization exists yet. Pass it to startAuthorization() or startAuthorizationWithId() instead. setAuthorizationMetadata() still works for finished authorizations. The README example is updated accordingly.

Starting an authorization code flow no longer writes to the database.
The data of the flow is kept in the state cache, and the authorization
is created when the flow finishes. Metadata for the authorization is
now passed to startAuthorization() or startAuthorizationWithId().

Previously, every start of a flow inserted an authorization row and
flushed the entity manager. Any browser which opened a page protected
by an OAuth or OpenID Connect login, including crawlers, caused a write
to the database, which also persisted unrelated pending changes of the
request. A flow which was never finished left its row behind until the
garbage collection removed it.

Because no row exists before the flow finishes,
setAuthorizationMetadata() can no longer attach metadata to a flow in
progress. It still changes the metadata of a finished authorization.
If startAuthorizationWithId() is called with the id of an existing
authorization, that authorization receives the new token and scope when
the flow finishes, and keeps its metadata unless new metadata was
passed.
Base automatically changed from task/callback-robustness to main September 14, 2026 12:52
@robertlemke
robertlemke merged commit 13655c4 into main Sep 14, 2026
@robertlemke
robertlemke deleted the task/flow-start-without-row branch September 14, 2026 12:53
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.

1 participant