nickva opened a new pull request #3586:
URL: https://github.com/apache/couchdb/pull/3586


   Previously, there were two ways to pass in basic auth credentials for
   endpoints -- using URL's userinfo part and encoding the them in an
   `"Authorization": "basic ..."` header. Neither one is ideal for these 
reasons:
   
    * Passwords in userinfo doesn't allow using ":", "@" and other characters.
      However, even after switching to always unquoting them like we did 
recently
      [1], would break authentication for usernames or passwords previously
      containing "+" or "%HH" patterns, as "+" might now be decoded to a " ".
   
    * Base64 encoded headers need an extra step to encode them. Also, quite 
often
      these encoded headers are confused as being "encrypted" and shared in a
      clear channel.
   
   To improve this, revert the recent commit to unquote URL userinfo parts to
   restore backwards compatibility, and introduce a way to pass in basic auth
   credentials in the "auth" object. The "auth" object was already added a while
   back to allow authentication plugins to store their credentials in it. The
   format is:
   
   ```
      "source": {
          "url": "https://host/db";,
          "auth": {
              "basic": {
                  "username":"myuser",
                  "password":"mypassword"
              }
          }
      }
   ```
   
   {"auth" : "basic" : {...}} object is checked first, and if credentials are
   provided, they will be used. If they are not then userinfo and basic auth
   header will be parsed.
   
   Internally, there was a good amount duplication related to parsing 
credentials
   from userinfo and headers in replication ID generation logic and in the auth
   session plugin. As a cleanup, consolidate that logic in the
   `couch_replicator_utils` module.
   
   [1] 
https://github.com/apache/couchdb/commit/f672b911db19981a81d7fc6ce8ac33b150234fd7
   
   <!-- Thank you for your contribution!
   
        Please file this form by replacing the Markdown comments
        with your text. If a section needs no action - remove it.
   
        Also remember, that CouchDB uses the Review-Then-Commit (RTC) model
        of code collaboration. Positive feedback is represented +1 from 
committers
        and negative is a -1. The -1 also means veto, and needs to be addressed
        to proceed. Once there are no objections, the PR can be merged by a
        CouchDB committer.
   
        See: http://couchdb.apache.org/bylaws.html#decisions for more info. -->
   
   ## Checklist
   
   - [x] Code is written and works correctly
   - [x] Changes are covered by tests
   - [x] Any new configurable parameters are documented in 
`rel/overlay/etc/default.ini`
   - [ ] A PR for documentation changes has been made in 
https://github.com/apache/couchdb-documentation (will create a docs pr after 
the review)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to