Allow models to use multpiple authentication tokens #356
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.
Looking for feedback on the implementation and if this is functionality that would be desired in the main repository. In the case that is, I will need to extend the software tests to cover the new functionality. Currently all existing tests are passing.
My use case:
I have a web application and a mobile application, both need to use authentication tokens and a user can be simultaneously using both. Unfortunately, I need the ability to invalidate tokens on one application and not the other, as such having only a single token field will not do.
Overview of implementation
In the case you wish to use more than one authentication token for a single model, the concept of 'providers' has been added to allow this.
When enabled, providers function alongside both authentication methods (Query params/Request headers) and work with all existing functionality. The only difference is that in order to validate a users token the provider must be present through either params or headers or both.
In the case you have multiple models, you can define them for a single model and all non-defined models will use default behaviour.
You could also enable this functionality simply to rename the default token field on a single model.