Skip to content
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

isAjax doesn't work with multiple accepted mime types #988

Closed
rassie opened this issue Jan 12, 2021 · 0 comments · Fixed by #989
Closed

isAjax doesn't work with multiple accepted mime types #988

rassie opened this issue Jan 12, 2021 · 0 comments · Fixed by #989

Comments

@rassie
Copy link
Contributor

rassie commented Jan 12, 2021

Expected Behavior

isAjax in oauthproxy.go should be iterating through different mime types for the Accept: field and return true if application/json is found.

Current Behavior

isAjax iterates over a single string. If this string matches application/json exactly, isAjax works as intended. With multiple mime types, as allowed by standards and default for Axios, isAjax fails to find the correct mime type. The following test fails, proving the point.

func TestAjaxUnauthorizedRequestAccept1(t *testing.T) {
	header := make(http.Header)
	header.Add("Accept", "application/json, text/plain, */*")

	testAjaxUnauthorizedRequest(t, header)
}

Possible Solution

Fix the loop to actually iterate over multiple mime types.

rassie added a commit to rassie/oauth2-proxy that referenced this issue Jan 12, 2021
rassie added a commit to rassie/oauth2-proxy that referenced this issue Jan 12, 2021
k-jell pushed a commit to liquidinvestigations/oauth2-proxy that referenced this issue Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant