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

Login no longer works for non root databases #215

Closed
Brimstedt opened this issue Jan 30, 2018 · 2 comments · Fixed by #216
Closed

Login no longer works for non root databases #215

Brimstedt opened this issue Jan 30, 2018 · 2 comments · Fixed by #216

Comments

@Brimstedt
Copy link

Brimstedt commented Jan 30, 2018

Expected Behavior

I expect to be able to login even if I have my database in a sub path on server:
https://xxx.yyy.com/db/dbname

In an older version, this was no problem

Current Behavior

After upgrading to the latest version of the pouchdb-authentication plugin, Im unable to login if I have couchdb proxied on a sub path.

Possible Solution

I think this is the breaking commit:
7472135

If I test the previously used regex, it would extract the url as https://xxx.yyy.com/db following my sample above. New method used (origin) returns only scheme + domain + port

Reverting those lines to using regex makes things work again.

Steps to Reproduce (for bugs)

  1. Put couchdb behind a proxy like nginx, proxying /db or similar to the db server
  2. Try logging in

Context

Unable to login users

Your Environment

  • Version of PouchDB Authentication: 1.1.1
  • Version of PouchDB: 6.4.2
  • Platform name and version: Browsers
  • Operating System and version: Linux, but most likely irrelevant
  • Server: CouchDB behing Nginx proxy
ptitjes added a commit to ptitjes/pouchdb-authentication that referenced this issue Jan 30, 2018
Databases can be proxied (nginx, express-pouch, ...) and be hosted
in a sub-path of a domain. This was not taken in account during
the refactoring to use url-parse (commit 7472135).

Fixes pouchdb-community#215
ptitjes added a commit to ptitjes/pouchdb-authentication that referenced this issue Jan 30, 2018
Databases can be proxied (nginx, express-pouch, ...) and be hosted
in a sub-path of a domain. This was not taken in account during
the refactoring to use url-parse (commit 7472135).

Fixes pouchdb-community#215
@ptitjes
Copy link
Collaborator

ptitjes commented Jan 31, 2018

Hi @Brimstedt. Thank you very much for bug report.

Would you mind looking at the new test case and corresponding fix in #216 ?

Note that the _session URLs used for authentication are build with the same base URL as _users URLs (cf. https://github.com/pouchdb-community/pouchdb-authentication/blob/master/src/utils.js#L22-L28). So the new test case covers both.

Please test it and tell me if that fits your requirements.

@Brimstedt
Copy link
Author

Hi, thanks for the quick fix.
I used your branch in my project and it seems to work well.

Unfortunately, I just get loads of errors when running the test suite, so I cannot verify tests. Code changes looks good though!

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.

2 participants