-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
🐛 Post-based identity bug fix #21533
Merged
dreamofabear
merged 9 commits into
ampproject:master
from
hellokoji:POST-identity-bug-fix
Apr 2, 2019
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
401bbfc
Force request POST transform with presence of crossorigin attribute.
hellokoji 9ce46e5
Remove unecessary win argument from xhrUtil function
hellokoji 0749f83
add getViewerAuthTokenIfAvailable tests to test-xhr-utils
hellokoji c3fd7b3
remove previous identity token test
hellokoji 40cfdf5
Restrict crossorigin attribute check to xhrUtils.
hellokoji 7b06f03
space
hellokoji 2e88d73
fix types
hellokoji 6dd2736
Merge remote-tracking branch 'upstream/master' into POST-identity-bug…
hellokoji aafe8c4
Address nit PR comments
hellokoji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative fix is to resolve with empty string instead of
undefined
, and then change the check inbatchFetchJsonFor
to compare against undefined instead of truthy. I.e.This preserves the current semantics by keeping the "crossorigin" attribute encapsulated in this helper function. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am okay with having the token return an empty string instead of undefined without a token, but it's important to still transform the request without a token based on the presence of the
crossorigin
attribute -- not the identity token.If I'm understanding your proposal correctly, the token would only be undefined in cases where
getViewerAuthTokenIfAvailable
isn't called at all. However,getViewerAuthTokenIfAvailable
will always be called inamp-state
andamp-list
before being passed to the batched-json call, so it will always transform the request into a POST because theopt_token !== undefined
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a clearer snippet of what I'm suggesting:
Would that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, that makes sense. This solution should work! Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made the changes and added some tests. Thanks for the suggestion!