Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coprocess: metadata access on post and post-key auth hooks #1577

Merged
merged 1 commit into from
Mar 29, 2018

Conversation

matiasinsaurralde
Copy link
Contributor

Following the report on #1536, we use coprocess.Object metadata field for our custom authentication mechanism, using implementations like this one:

	object.Session = &coprocess.SessionState{
		Rate: 1000.0,
		Per:  1.0,
	}
	object.Metadata = map[string]string{
		"token":   validKey,
		"metakey": "metavalue",
	}

	return object, nil

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) uses interface{} which was trickier to use with Protobuf in the past (see here). For a better support we might modify the coprocess.Session.Metadata field to use the Protobuf.Any type.
This patch doesn't break the compatibility with existing custom authentication implementations but adds missing data useful for a few scenarios.

@buger
Copy link
Member

buger commented Mar 29, 2018

Make sense.

Pls update the docs, and inform customer how to use this feature.

@buger buger merged commit 8504c41 into TykTechnologies:master Mar 29, 2018
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.

2 participants