Repository navigation
Store an authorization only when its flow finishes - #46
Merged
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tostartAuthorization()orstartAuthorizationWithId()instead.setAuthorizationMetadata()still works for finished authorizations. The README example is updated accordingly.