Closed nakulsaini closed 6 years ago
I'm guessing that this is due to IE's caching of GET requests. Can you confirm that the GET request contains something like ?_nonce=<random string>
? That's our trick for busting the cache in IE, and it should be working here as well.
Yes.
http://COUCHDB_IP:5984/_session?_nonce=1437368577183
This is the URL for GET request.
It gives these errors:
whereas CORS is enabled properly over CouchDB and working with other browsers.
Hm, how did you enable CORS? If you used add-cors-to-couchdb
, it's possible that there's still a header missing for IE11 to work properly. I've definitely seen lots of cross-browser differences when it comes to CORS.
same here I have updated headers as per add-cors-to-couchdb, restarted but it's still throwing those CORS errors on IE
There is probably some header that add-cors-to-couchdb is missing for IE; I would love if somebody would investigate and try to figure it out, since I don't have access to a Windows machine. :)
I'm just starting to investigate.. Same boat without IE to debug with.
Our _session
response seems to be okay, but then replication fails with a 401. The CouchDB server is on a separate domain.
The person who reported to me mentioned P3P policies and 3rd party cookies. Which I guess could make this a CouchDB response headers issue.
edit: Can't find any way to configure adding custom headers to CouchDB...
Was investigating using a CouchDB show
to return /w3c/p3p.xml
.
IE is sending an OPTIONS
preflight for CORs. However no hit is made for a static XML version.
It would appear that CouchDB itself should be sending a dodgy p3p=potato
header to be compatible with IE browsers.
Did you enable CORS with https://github.com/pouchdb/add-cors-to-couchdb ?
CORS enabled in my case. Not actually using pouchdb-authentication
but seeing the same issue.
Worked around it by adding HTTP basic auth to my system.
I have the same problem like @nakulsaini with ie11, ios 8 and ios 9.2.1
{"ok":true,"userCtx":{"name":null,"roles":[]},"info":{"authentication_db":"_users","authentication_handlers":["oauth","cookie","default"]}}
But only on local developement. The following lines are in the couchdb local.ini:
[httpd]
enable_cors = true
[cors]
credentials: true
headers: accept, authorization, content-type, origin, referer, cache-control, x-requested-with
methods: GET,PUT,POST,HEAD,DELETE
origins: *
origins = *
credentials = true
I have similar issues on iOS 9.2.1, on IE 11 for WP8.1 and on MS Edge (on IE 11 for desktop it seems to work). On caniuse they mention in the known issues that
IE10+ does not make a CORS request if port is the only difference (IE Bug #781303)
As I was serving my app from http://localhost and CouchDB from http://localhost:5984, I thought I found the cause. So moved the database to another machine and it seemed to work fine on iOS and WP, but still no luck on Edge on the desktop.
The next issue on caniuse mentions the P3P protocol, so I spent quite some time looking into that until I found the post that this is dropped for ie 11 and Edge.
The machine I moved the CouchDB to was the same as I was testing Edge on. And Edge is not so friendly to localhost testing.
As I'm running out of machines here, I moved the Couch to Amazon AWS, and now it all works. Right in time for the friday night drinks...
Ah OK that's interesting; I didn't know that about the separate ports and IE/Edge. In general, though, I will say that CORS is really really tricky to get working, and even once you actually get it working, you take a performance hit because every request has to do an extra preflight request. So for that reason, I typically tell people to avoid CORS in production, e.g. by using an Nginx or Apache reverse proxy. So e.g. your website would be website.com
and your couchdb would be hosted at website.com/couchdb
: https://wiki.apache.org/couchdb/Nginx_As_a_Reverse_Proxy
@nolanlawson I ran the test suite on IE11 on SauceLab and indeed it fails whereas it succeeds on IE10. (Test log bellow.) I even tried to add the OPTIONS
method (following @mryellow's https://github.com/pouchdb-community/pouchdb-authentication/issues/45#issuecomment-175235689) to what add-cors-to-couchdb
already set, but this changes nothing. It appears that both Test login/logout
and Test wrong user for getUser
fail after getSession()
returns a response with null userCtx.name
. The other four failures are more intricate but I suspect a similar problem with getUser()
.
I don't know where to go from there, especially as I don't have any Windows machine around...
@nakulsaini, @fgrs, @mryellow, @webdesignberlin, @erik127, could one of you please run the test suite on a Windows machine with IE11 and give us the headers and responses of the ajax requests ?
$ CLIENT="saucelabs:internet explorer:10:Windows 8" npm run test
> pouchdb-authentication@0.5.5 test /home/didier/Code/external/pouchdb-authentication
> npm run rollup-cjs && node bin/run-test.js
> pouchdb-authentication@0.5.5 rollup-cjs /home/didier/Code/external/pouchdb-authentication
> rollup -c config/rollup.config.cjs.js && rollup -c config/rollup.config.browser.cjs.js
src/index.js → lib/index.js...
created lib/index.js in 128ms
src/index.js → lib/index.browser.js...
created lib/index.browser.js in 124ms
START:
20 11 2017 00:27:22.286:INFO [framework.browserify]: bundle built
20 11 2017 00:27:22.297:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
20 11 2017 00:27:22.298:INFO [launcher]: Launching browser sl with concurrency 1
20 11 2017 00:27:22.353:INFO [launcher]: Starting browser internet explorer 10 (Windows 8) on SauceLabs
20 11 2017 00:27:48.277:INFO [launcher.sauce]: internet explorer 10 (Windows 8) session at https://saucelabs.com/tests/139adad522e74dbabea0c38d56b30b9a
20 11 2017 00:27:50.794:INFO [IE 10.0.0 (Windows 8 0.0.0)]: Connected on socket 6StYw-xpKbxJJu9oAAAA with id 95887411
IE 10.0.0 (Windows 8 0.0.0) ERROR: 'This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
authentication
✔ Test signup
✔ Test signup conflict
✔ Test bad signup args
✔ Test bad signup args 2
✔ Test login/logout
✔ Test metadata
✔ Test changing metadata
✔ Test changing metadata using reserved word "_id"
✔ Test changing metadata using reserved word "_rev"
✔ Test changing metadata using reserved word "name"
✔ Test changing metadata using reserved word "type"
✔ Test changing metadata using reserved word "roles"
✔ Test changing metadata using reserved word "password"
✔ Test changing metadata using reserved word "password_scheme"
✔ Test changing metadata using reserved word "iterations"
✔ Test changing metadata using reserved word "derived_key"
✔ Test changing metadata using reserved word "salt"
✔ Test changing metadata using non-reserved word "metadata"
✔ Test that admin can change roles
✔ Test that user cannot change roles
✔ Test wrong user for getUser
✔ Test change password
✔ Test change username
✔ Shouldn't change username if new username already exists
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
Finished in 1 min 20.919 secs / 37.461 secs @ 00:29:17 GMT+0100 (CET)
SUMMARY:
✔ 29 tests completed
20 11 2017 00:29:17.593:INFO [launcher.sauce]: Shutting down Sauce Connect
$ CLIENT="saucelabs:internet explorer:11:Windows 10" npm run test
> pouchdb-authentication@0.5.5 test /home/didier/Code/external/pouchdb-authentication
> npm run rollup-cjs && node bin/run-test.js
> pouchdb-authentication@0.5.5 rollup-cjs /home/didier/Code/external/pouchdb-authentication
> rollup -c config/rollup.config.cjs.js && rollup -c config/rollup.config.browser.cjs.js
src/index.js → lib/index.js...
created lib/index.js in 116ms
src/index.js → lib/index.browser.js...
created lib/index.browser.js in 119ms
START:
20 11 2017 00:37:41.775:INFO [framework.browserify]: bundle built
20 11 2017 00:37:41.787:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
20 11 2017 00:37:41.788:INFO [launcher]: Launching browser sl with concurrency 1
20 11 2017 00:37:41.853:INFO [launcher]: Starting browser internet explorer 11 (Windows 10) on SauceLabs
20 11 2017 00:38:12.946:INFO [launcher.sauce]: internet explorer 11 (Windows 10) session at https://saucelabs.com/tests/120168a5872842289f1cf37381753af4
20 11 2017 00:38:15.512:INFO [IE 11.0.0 (Windows 10 0.0.0)]: Connected on socket FZoAJNSTfjklXXZMAAAA with id 42875832
authentication
✔ Test signup
✔ Test signup conflict
✔ Test bad signup args
✔ Test bad signup args 2
✖ Test login/logout
✔ Test metadata
✖ Test changing metadata
✔ Test changing metadata using reserved word "_id"
✔ Test changing metadata using reserved word "_rev"
✔ Test changing metadata using reserved word "name"
✔ Test changing metadata using reserved word "type"
✔ Test changing metadata using reserved word "roles"
✔ Test changing metadata using reserved word "password"
✔ Test changing metadata using reserved word "password_scheme"
✔ Test changing metadata using reserved word "iterations"
✔ Test changing metadata using reserved word "derived_key"
✔ Test changing metadata using reserved word "salt"
✖ Test changing metadata using non-reserved word "metadata"
✖ Test that admin can change roles
✔ Test that user cannot change roles
✖ Test wrong user for getUser
✔ Test change password
✖ Test change username
✔ Shouldn't change username if new username already exists
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
Finished in 1 min 54.836 secs / 48.66 secs @ 00:40:14 GMT+0100 (CET)
SUMMARY:
✔ 23 tests completed
✖ 6 tests failed
FAILED TESTS:
authentication
✖ Test login/logout
IE 11.0.0 (Windows 10 0.0.0)
TypeError: Unable to get property 'should' of undefined or null reference
at Anonymous function (/tmp/test/test.authentication.js:87:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:45346:7)
at Anonymous function (/tmp/node_modules/lie/lib/browser.js:73:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:15762:7)
at nextTick (/tmp/node_modules/immediate/lib/browser.js:57:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:12430:7)
✖ Test changing metadata
IE 11.0.0 (Windows 10 0.0.0)
Document update conflict.
✖ Test changing metadata using non-reserved word "metadata"
IE 11.0.0 (Windows 10 0.0.0)
expected { Object (error, reason, ...) } to not exist
Error
at AssertionError (/tmp/node_modules/assertion-error/index.js:74:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:858:7)
at Assertion.prototype.assert (/tmp/node_modules/chai/lib/chai/assertion.js:107:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:3501:7)
at Anonymous function (/tmp/node_modules/chai/lib/chai/core/assertions.js:389:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:3973:5)
at addProperty (/tmp/node_modules/chai/lib/chai/utils/addProperty.js:43:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:7535:9)
at doAsserterAsyncAndAddThen (/tmp/node_modules/chai-as-promised/lib/chai-as-promised.js:296:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:3215:17)
at Anonymous function (/tmp/node_modules/chai-as-promised/lib/chai-as-promised.js:286:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:3205:25)
at to.get (/tmp/node_modules/chai/lib/chai/utils/overwriteProperty.js:50:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:8691:9)
at should.not.exist (/tmp/node_modules/chai/lib/chai/interface/should.js:190:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:7319:7)
at Anonymous function (/tmp/test/test.authentication.js:198:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:45457:7)
at Anonymous function (/tmp/node_modules/lie/lib/browser.js:73:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:15762:7)
✖ Test that admin can change roles
IE 11.0.0 (Windows 10 0.0.0)
expected { Object (message, showDiff, ...) } to not exist
Error
at AssertionError (/tmp/node_modules/assertion-error/index.js:74:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:858:7)
at Assertion.prototype.assert (/tmp/node_modules/chai/lib/chai/assertion.js:107:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:3501:7)
at Anonymous function (/tmp/node_modules/chai/lib/chai/core/assertions.js:389:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:3973:5)
at addProperty (/tmp/node_modules/chai/lib/chai/utils/addProperty.js:43:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:7535:9)
at doAsserterAsyncAndAddThen (/tmp/node_modules/chai-as-promised/lib/chai-as-promised.js:296:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:3215:17)
at Anonymous function (/tmp/node_modules/chai-as-promised/lib/chai-as-promised.js:286:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:3205:25)
at to.get (/tmp/node_modules/chai/lib/chai/utils/overwriteProperty.js:50:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:8691:9)
at should.not.exist (/tmp/node_modules/chai/lib/chai/interface/should.js:190:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:7319:7)
at Anonymous function (/tmp/test/test.authentication.js:218:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:45477:7)
at Anonymous function (/tmp/node_modules/lie/lib/browser.js:73:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:15762:7)
✖ Test wrong user for getUser
IE 11.0.0 (Windows 10 0.0.0)
TypeError: Unable to get property 'should' of undefined or null reference
at Anonymous function (/tmp/test/test.authentication.js:264:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:45523:13)
at Anonymous function (/tmp/node_modules/lie/lib/browser.js:73:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:15762:7)
at nextTick (/tmp/node_modules/immediate/lib/browser.js:57:0 <- /tmp/bcfc7ad3c2399a3c59276e72e07b980f.browserify:12430:7)
✖ Test change username
IE 11.0.0 (Windows 10 0.0.0)
Document update conflict.
20 11 2017 00:40:14.350:INFO [launcher.sauce]: Shutting down Sauce Connect
@nolanlawson I finally made the test suite work thanks to the patch of #145 "disable cache for GET auth requests; fixes IE 11 caching issues". So it seems this is a bug of pouchdb-ajax
sniffing then.
I found some MSDN resources explaining that the IE11 user-agent string doesn't include "MSIE" anymore [1], [2], [3], [4]. From what I understand, it should also match for "Trident" which seems to be present in all recent IE user-agent strings... I will open an issue on pouchdb-ajax
.
CLIENT="saucelabs:internet explorer:11:Windows 10" npm run test
> pouchdb-authentication@0.5.5 test /home/didier/Code/external/pouchdb-authentication
> npm run rollup-cjs && node bin/run-test.js
> pouchdb-authentication@0.5.5 rollup-cjs /home/didier/Code/external/pouchdb-authentication
> rollup -c config/rollup.config.cjs.js && rollup -c config/rollup.config.browser.cjs.js
src/index.js → lib/index.js...
created lib/index.js in 122ms
src/index.js → lib/index.browser.js...
created lib/index.browser.js in 125ms
START:
20 11 2017 02:04:11.070:INFO [framework.browserify]: bundle built
20 11 2017 02:04:11.088:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
20 11 2017 02:04:11.088:INFO [launcher]: Launching browser sl with concurrency 1
20 11 2017 02:04:11.128:INFO [launcher]: Starting browser internet explorer 11 (Windows 10) on SauceLabs
20 11 2017 02:04:42.951:INFO [launcher.sauce]: internet explorer 11 (Windows 10) session at https://saucelabs.com/tests/8a8e1cc8bd95428b9196f7e6bd73b7b6
20 11 2017 02:04:45.002:INFO [IE 11.0.0 (Windows 10 0.0.0)]: Connected on socket rr5g_DDb3NtK3ATnAAAA with id 21995278
authentication
✔ Test signup
✔ Test signup conflict
✔ Test bad signup args
✔ Test bad signup args 2
✔ Test login/logout
✔ Test metadata
✔ Test changing metadata
✔ Test changing metadata using reserved word "_id"
✔ Test changing metadata using reserved word "_rev"
✔ Test changing metadata using reserved word "name"
✔ Test changing metadata using reserved word "type"
✔ Test changing metadata using reserved word "roles"
✔ Test changing metadata using reserved word "password"
✔ Test changing metadata using reserved word "password_scheme"
✔ Test changing metadata using reserved word "iterations"
✔ Test changing metadata using reserved word "derived_key"
✔ Test changing metadata using reserved word "salt"
✔ Test changing metadata using non-reserved word "metadata"
✔ Test that admin can change roles
✔ Test that user cannot change roles
✔ Test wrong user for getUser
✔ Test change password
✔ Test change username
✔ Shouldn't change username if new username already exists
urls
✔ Correct users database url for database without trailing slash
✔ Correct users database url for database with trailing slash
✔ Correct users database url using prefix without trailing slash
✔ Correct users database url using prefix with trailing slash
✔ Correct users database url for cloudant-style database urls
Finished in 1 min 51.609 secs / 52.817 secs @ 02:06:41 GMT+0100 (CET)
SUMMARY:
✔ 29 tests completed
20 11 2017 02:06:41.363:INFO [launcher.sauce]: Shutting down Sauce Connect
Blocked by pouchdb/pouchdb#6855.
I will close this issue as soon as user-agent sniffing gets fixed upstream. Corresponding upstream issue pouchdb/pouchdb#6855 and PR pouchdb/pouchdb#6856.
Fixed in f0c45b542b58e5083de5aa0f843c765f425a97f5 by bumping PouchDB to 6.4.0.
We are using pouchdb-authentication as authentication process for PouchDB. Its working great with Firefox and Chrome but not in IE.
For example:
Response in Firefox/Chrome:
Response in IE:
Is there any specific option for IE we are missing or it needs some configuration over CouchDB?