Add state param to OAuth provider #529
Merged
+39
−0
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.
Adds the ability for a
state
parameter to be provided by the OAuth client provider.Motivation and Context
The current auth implementation does not allow for a
state
parameter to be passed into the authorize url. It's fairly common for OAuth implementations to mandate the inclusion of a state parameter for security purposes. For example, Ory, a popular OAuth server implementation, will reject requests without a state parameter. In order to maximize compatibility with OAuth servers, adding the option to include a state parameter I think would be useful.In cases where the developer does not have the means to or does not desire to pass a state parameter, defining this is optional, so it will still work as previously if state is not present as a function on the OAuth client provider.
How Has This Been Tested?
I added passing tests for the state param being present and absent into the auth test suite. I also took this patch and applied it to a project I am working on that utilizes an OAuth server that requires the state parameter to be present, and verified that with this change, the state parameter was added and the OAuth flow was able to be completed.
Breaking Changes
This should not be breaking at all.
Types of changes
Checklist
Additional context
I have several more improvements to the auth handling code in my personal queue - I would love to establish a line of communication with whoever is maintaining this area of the codebase currently in order to be able to discuss proposed changed before submitting PRs to make sure that I'm directionally aligned. If anyone is willing to connect with me that would be wonderful! In the meantime, I'll continue working on getting PRs submitted 🚀