-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
MM-11160 Adding proper CORS support. #9152
Conversation
api4/cors_test.go
Outdated
req.Header.Set("Origin", "http://mattermost.com") | ||
}, | ||
func(t *testing.T, resp *http.Response) { | ||
for name, headers := range resp.Header { |
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.
Should this t.Log
block just be part of the t.Run
?
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.
No that was just me debugging that test. Will remove.
api4/cors_test.go
Outdated
assert.Equal(t, http.StatusOK, resp.StatusCode) | ||
assert.Equal(t, "*", resp.Header.Get(acAllowOrigin)) | ||
assert.Equal(t, "", resp.Header.Get(acExposeHeaders)) | ||
assert.Equal(t, "", resp.Header.Get(acAllowCredentials)) |
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.
nit: Any reason why we're not testing all the headers in each test case?
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.
Because those headers aren't appropriate in that situation. Wanted to avoid unnecessary checks.
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.
That's fair, but it's not obvious why we're checking them at all in the first place. Take, for example, acMaxAge
: we only check that it's empty twice. Why do we need to assert that?
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.
Paranoia. Really we don't. It doesn't matter if that's set because it's only for preflight requests.
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.
2/5, but I think we should either check the "expected" empty value for paranoia reasons in all cases, or not at all. Its special status here is confusing :)
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.
OK I fixed it.
@crspeller @lieut-data thanks for this update, but with 5.7.0 I am still having issues with Client4 on Firefox, namely getting |
@iampeter Have you set the appropriate config settings? |
here's my setup:
and an excerpt from the log:
Chrome is fine - this happens in Firefox. |
@iampeter Hmm. Your going to need to explain in more detail what you are trying to accomplish. Can we take this conversation over to our community server? The |
@crspeller sure let's do this. what timezone are you in? |
@iampeter Vancouver time (PST) |
Adds proper support for CORS. This should support embedding cases even when the requester needs credentials.
Good resource to understand what this is all about: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
New settings:
Access-Control-Allow-Credentials
header.Resolves: mattermost/mattermost-redux#557 , #8687
All test cases in the above issues pass with the proper configuration.