-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support receiving JSON values from Webhooks/JWT/NoAuth instead of jus…
…t strings (#1257) ### What Previously, we only supported String as the type that contained your session variable value when they are provided from webhooks/JWT/NoAuth. We then coerced that value into whatever type was actually expected (eg a float) later. However, when we added support for array-typed session variables (#1221) we didn't actually allow you to provide a JSON array of values as a session variable value. You had to provide a string that contained a JSON-encoded array of values. This meant that webhooks/JWT/NoAuth had to double JSON-encode their session variables when returning them. This PR fixes this and makes it so that webhooks/JWT/NoAuth can return JSON values for session variables and that JSON is respected. So if a session variable needs to be an array of integers, they can simply return the JSON array of integers as the value for that session variable. ### How Instead of holding a `SessionVariableValue` as a `String`, we now turn that into an enum where we have an "unparsed" String (used for when we don't receive JSON, we just receive a string value (ie. http headers)), or a "parsed" JSON value. When we receive session variables from webhooks/JWT/NoAuth, we relax the restriction that they can only return us JSON strings, and instead allow them to return JSON Values, which we put in the new `SessionVariableValue::Parsed` enum variant. HTTP headers go into `SessionVariableValue::Unparsed`. Then, when we go to get the required value from the `SessionVariableValue` based on the desired type, we either parse it out of the "unparsed" String, or we expect that the value is already in the correct form in the "parsed" JSON value. This is the behaviour you will get if JSON session variables are turned on in the Flags. If JSON session variables are not turned on, then we expect that only String session variables (parsed or unparsed) are provided from headers/webhooks/JWT/NoAuth, and so we run the old logic of always expecting a String and parsing the correct value out of it. V3_GIT_ORIGIN_REV_ID: b6734ad5443b7d68065f91aea71386c893aa7eba
- Loading branch information
1 parent
997d147
commit f68438b
Showing
34 changed files
with
840 additions
and
124 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.