File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ var defaultLocalhostOrigins = []string{
44
44
"https://[::1]:<port>" ,
45
45
"http://localhost:<port>" ,
46
46
"https://localhost:<port>" ,
47
+ "chrome-extension://nibjojkomfdiaoajekhjakgkdhaomnch" , // ipfs-companion
48
+ "chrome-extension://hjoieblefckbooibpepigmacodalfndh" // ipfs-companion-beta
47
49
}
48
50
49
51
func addCORSFromEnv (c * cmdsHttp.ServerConfig ) {
Original file line number Diff line number Diff line change @@ -39,6 +39,21 @@ test_expect_success "browser is able to access API if Origin is the API port on
39
39
grep "HTTP/1.1 200 OK" curl_output && grep "$PEERID" curl_output
40
40
'
41
41
42
+ test_expect_success " Companion extension is unable to access API with invalid Origin" '
43
+ curl -sD - -X POST -A "Mozilla" -H "Origin: chrome-extension://invalidextensionid" "http://127.0.0.1:$API_PORT/api/v0/id" >curl_output &&
44
+ grep "HTTP/1.1 403 Forbidden" curl_output
45
+ '
46
+
47
+ test_expect_success " Companion extension is able to access API if Origin is the API port on localhost (ipv4)" '
48
+ curl -sD - -X POST -A "Mozilla" -H "Origin: chrome-extension://nibjojkomfdiaoajekhjakgkdhaomnch" "http://127.0.0.1:$API_PORT/api/v0/id" >curl_output &&
49
+ grep "HTTP/1.1 200 OK" curl_output && grep "$PEERID" curl_output
50
+ '
51
+
52
+ test_expect_success " Companion beta extension is able to access API if Origin is the API port on localhost (ipv4)" '
53
+ curl -sD - -X POST -A "Mozilla" -H "Origin: chrome-extension://hjoieblefckbooibpepigmacodalfndh" "http://127.0.0.1:$API_PORT/api/v0/id" >curl_output &&
54
+ grep "HTTP/1.1 200 OK" curl_output && grep "$PEERID" curl_output
55
+ '
56
+
42
57
test_kill_ipfs_daemon
43
58
44
59
test_expect_success " setting CORS in API.HTTPHeaders works via CLI" "
You can’t perform that action at this time.
0 commit comments