This repository was archived by the owner on Mar 11, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +18
-5
lines changed
Expand file tree Collapse file tree 5 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 11# UNRELEASED
22- [ FIXED] Expose BasePlugin.
3+ - [ FIXED] Prevent double encoding of credentials passed in URL user information
4+ when using the ` cookieauth ` plugin.
5+ - [ IMPROVED] Documented the characters that are required to be encoded in URL
6+ user information.
37- [ IMPROVED] Documented the legacy compatibility behaviour that always adds the
48 ` cookieauth ` plugin when using the initialization callback functionality.
59
Original file line number Diff line number Diff line change @@ -156,6 +156,13 @@ var Cloudant = require('@cloudant/cloudant');
156156var cloudant = Cloudant (" http://MYUSERNAME:MYPASSWORD@localhost:5984" );
157157~~~
158158
159+ ** Note** : If you pass credentials in the user information subcomponent of the URL
160+ then they must be [ percent encoded] ( https://tools.ietf.org/html/rfc3986#section-3.2.1 ) .
161+ Specifically the characters ` : / ? # [ ] @ % ` _ MUST_ be precent-encoded, other
162+ characters _ MAY_ be percent encoded.
163+ Credentials must not be percent encoded when passing them via other configuration
164+ options besides ` url ` .
165+
159166** Note** : If you pass in a ` username ` , ` password ` , and ` url ` that contains
160167credentials, the ` username ` and ` password ` will supercede the credentials within
161168the ` url ` . For example, ` myusername ` and ` mypassword ` will be used in the code
Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ class CookieTokenManager extends TokenManager {
2929 this . _client ( {
3030 url : this . _sessionUrl ,
3131 method : 'POST' ,
32- form : {
32+ json : true ,
33+ body : {
3334 name : this . _username ,
3435 password : this . _password
3536 } ,
Original file line number Diff line number Diff line change @@ -49,8 +49,9 @@ class CookiePlugin extends BasePlugin {
4949 client ,
5050 this . _jar ,
5151 u . format ( sessionUrl , { auth : false } ) ,
52- sessionUrl . username ,
53- sessionUrl . password
52+ // Extract creds from URL and decode
53+ decodeURIComponent ( sessionUrl . username ) ,
54+ decodeURIComponent ( sessionUrl . password )
5455 ) ;
5556
5657 if ( cfg . autoRenew ) {
Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ const nock = require('../nock.js');
2121const uuidv4 = require ( 'uuid/v4' ) ; // random
2222
2323const ME = process . env . cloudant_username || 'nodejs' ;
24- const PASSWORD = process . env . cloudant_password || 'sjedon' ;
24+ const PASSWORD = process . env . cloudant_password || 'sjedon!@#"£$%^&*() ' ;
2525const SERVER = process . env . SERVER_URL || `https://${ ME } .cloudant.com` ;
2626const SERVER_NO_PROTOCOL = SERVER . replace ( / ^ h t t p s ? : \/ \/ / , '' ) ;
27- const SERVER_WITH_CREDS = `https://${ ME } :${ PASSWORD } @${ SERVER_NO_PROTOCOL } ` ;
27+ const SERVER_WITH_CREDS = `https://${ ME } :${ encodeURIComponent ( PASSWORD ) } @${ SERVER_NO_PROTOCOL } ` ;
2828const DBNAME = `/nodejs-cloudant-${ uuidv4 ( ) } ` ;
2929const COOKIEAUTH_PLUGIN = [ { cookieauth : { autoRenew : false } } ] ;
3030
You can’t perform that action at this time.
0 commit comments