coprocess: metadata access on post and post-key auth hooks #1577
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.
Following the report on #1536, we use
coprocess.Object
metadata field for our custom authentication mechanism, using implementations like this one:This works fine for custom authentication or the ID extractor mechanism itself (to extract the key only) however the metadata is ignored when
SessionManager.UpdateSession
is called, this patch fixes this.Additionally, it makes sure that an encoded session object includes metadata values (the encoded session object is used by post and post-key auth hooks).
The reason why we used
coprocess.Object.Metadata
instead of interacting with the session metadata field directly is that the native structure (not the Protobuf-generated one) usesinterface{}
which was trickier to use with Protobuf in the past (see here). For a better support we might modify thecoprocess.Session.Metadata
field to use theProtobuf.Any
type.This patch doesn't break the compatibility with existing custom authentication implementations but adds missing data useful for a few scenarios.