{"action":"created","issue":{"url":"https://api.github.com/repos/logstash-plugins/logstash-input-http/issues/83","repository_url":"https://api.github.com/repos/logstash-plugins/logstash-input-http","labels_url":"https://api.github.com/repos/logstash-plugins/logstash-input-http/issues/83/labels{/name}","comments_url":"https://api.github.com/repos/logstash-plugins/logstash-input-http/issues/83/comments","events_url":"https://api.github.com/repos/logstash-plugins/logstash-input-http/issues/83/events","html_url":"https://github.com/logstash-plugins/logstash-input-http/issues/83","id":311903132,"node_id":"MDU6SXNzdWUzMTE5MDMxMzI=","number":83,"title":"Access control for browsers stops working when basic auth is enabled","user":{"login":"pkoretic","id":1131063,"node_id":"MDQ6VXNlcjExMzEwNjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1131063?v=4","gravatar_id":"","url":"https://api.github.com/users/pkoretic","html_url":"https://github.com/pkoretic","followers_url":"https://api.github.com/users/pkoretic/followers","following_url":"https://api.github.com/users/pkoretic/following{/other_user}","gists_url":"https://api.github.com/users/pkoretic/gists{/gist_id}","starred_url":"https://api.github.com/users/pkoretic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkoretic/subscriptions","organizations_url":"https://api.github.com/users/pkoretic/orgs","repos_url":"https://api.github.com/users/pkoretic/repos","events_url":"https://api.github.com/users/pkoretic/events{/privacy}","received_events_url":"https://api.github.com/users/pkoretic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-04-06T09:13:28Z","updated_at":"2018-12-17T12:05:29Z","closed_at":null,"author_association":"NONE","body":"- Elastic 6.2.3\r\n\r\nLogstash config file\r\n```\r\ninput {\r\n\thttp {\r\n\t\tuser => \"some\"\r\n\t\tpassword => \"one\"\r\n\t\tport => 38080\r\n\t\tcodec => json\r\n                response_headers => {\r\n                    \"Access-Control-Allow-Origin\" => \"*\"\r\n                    \"Content-Type\" => \"text/plain\"\r\n                    \"Access-Control-Allow-Headers\" => \"*\"\r\n                }\r\n\t}\r\n}\r\n```\r\n\r\nThis works as expected in non browser environment while in browser when POST request is made (`xhr.open(\"POST\", \"http://localhost:38080\", true, \"some\", \"one\")`) this results in (*Chrome 65.0.3325.181*)\r\n\r\n> OPTIONS http://localhost:38080/ 401 (Unauthorized)\r\nResponse to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.\r\n\r\nRemoving `user` / `password`  fields this works as expected. No difference with other options like `Access-Control-Allow-Methods`. It just seems to me like this is handled by plugin internally because this is what I see in wireshark:\r\n\r\n>OPTIONS / HTTP/1.1\r\nHost: localhost:38080\r\nConnection: keep-alive\r\nAccess-Control-Request-Method: POST\r\nOrigin: http://127.0.0.1:3333\r\nUser-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36\r\nAccess-Control-Request-Headers: authorization,content-type\r\nAccept: */*\r\nDNT: 1\r\nAccept-Encoding: gzip, deflate, br\r\nAccept-Language: en-US,en;q=0.9,hr-HR;q=0.8,hr;q=0.7\r\n\r\n>HTTP/1.1 401 Unauthorized\r\nContent-Type: text/plain\r\nWWW-Authenticate: Basic realm=\"\"\r\nContent-Length: 0\r\n\r\nThis should return response_headers so that client can authenticate. I found same working example here, although this also uses ssl which I haven't tried yet (and only curl is used so I can't say if browsers are working):\r\nhttps://discuss.elastic.co/t/http-input-with-ssl/115338\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/logstash-plugins/logstash-input-http/issues/comments/447822034","html_url":"https://github.com/logstash-plugins/logstash-input-http/issues/83#issuecomment-447822034","issue_url":"https://api.github.com/repos/logstash-plugins/logstash-input-http/issues/83","id":447822034,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzgyMjAzNA==","user":{"login":"pkoretic","id":1131063,"node_id":"MDQ6VXNlcjExMzEwNjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1131063?v=4","gravatar_id":"","url":"https://api.github.com/users/pkoretic","html_url":"https://github.com/pkoretic","followers_url":"https://api.github.com/users/pkoretic/followers","following_url":"https://api.github.com/users/pkoretic/following{/other_user}","gists_url":"https://api.github.com/users/pkoretic/gists{/gist_id}","starred_url":"https://api.github.com/users/pkoretic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkoretic/subscriptions","organizations_url":"https://api.github.com/users/pkoretic/orgs","repos_url":"https://api.github.com/users/pkoretic/repos","events_url":"https://api.github.com/users/pkoretic/events{/privacy}","received_events_url":"https://api.github.com/users/pkoretic/received_events","type":"User","site_admin":false},"created_at":"2018-12-17T12:05:29Z","updated_at":"2018-12-17T12:05:29Z","author_association":"NONE","body":"@antgel ah, then you are here https://discuss.elastic.co/t/post-data-to-logstash-using-http-input/69166/7 :)"}}
{"actor":{"display_login":"pkoretic"}}