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

Add correct access control headers to the default api config #1979

Merged
merged 3 commits into from
Dec 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions repo/config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
API: "/ip4/127.0.0.1/tcp/5001",
Gateway: "/ip4/127.0.0.1/tcp/8080",
},
API: API{
HTTPHeaders: map[string][]string{
"Access-Control-Allow-Headers": []string{
"X-Stream-Output, X-Chunked-Output",
},
"Access-Control-Expose-Headers": []string{
"X-Stream-Output, X-Chunked-Output",
},
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add them also to Gateway, because gateway also has an API. (we need to rename these... not sure on good names)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbenet sorry not sure where exactly, do you mean on l. 83?


Bootstrap: BootstrapPeerStrings(bootstrapPeers),
SupernodeRouting: *snr,
Expand Down Expand Up @@ -71,6 +81,14 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
Gateway: Gateway{
RootRedirect: "",
Writable: false,
HTTPHeaders: map[string][]string{
"Access-Control-Allow-Headers": []string{
"X-Stream-Output, X-Chunked-Output",
},
"Access-Control-Expose-Headers": []string{
"X-Stream-Output, X-Chunked-Output",
},
},
},
}

Expand Down
4 changes: 4 additions & 0 deletions test/sharness/t0230-channel-streaming-http-content-type.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ test_ls_cmd() {

test_expect_success "Text encoded channel-streaming command output looks good" '
printf "HTTP/1.1 200 OK\r\n" >expected_output &&
printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output &&
printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output &&
printf "Content-Type: text/plain\r\n" >>expected_output &&
printf "Trailer: X-Stream-Error\r\n" >>expected_output &&
printf "Transfer-Encoding: chunked\r\n" >>expected_output &&
Expand All @@ -41,6 +43,8 @@ test_ls_cmd() {

test_expect_success "JSON encoded channel-streaming command output looks good" '
printf "HTTP/1.1 200 OK\r\n" >expected_output &&
printf "Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output &&
printf "Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output\r\n" >>expected_output &&
printf "Content-Type: application/json\r\n" >>expected_output &&
printf "Trailer: X-Stream-Error\r\n" >>expected_output &&
printf "Transfer-Encoding: chunked\r\n" >>expected_output &&
Expand Down