Package: p01.buildouthttp
=========================HTTP plugins for buildout=========================HTTP Basic-Authentication=========================With this extension it is possible to define password protectedpackage directories without specifying the password and user in theurl.Let's take the example protected location, ``http://www.example.com/dist``First we would need to add the extension and the find link for ourprotected location::[buildout]find-links = http://www.example.com/distextensions = p01.buildouthttpThen create the ``.httpauth`` password file, this file contains allauthentication information. The ``.httpauth`` file can be placed in the root ofthe current buildout or in the ``~/.buildout`` directory. Each row consists of``realm, uri, username, password``.Here is an example of the ``.httpauth`` file::Example com realm, http://www.example.com, username, secretIt is also possible to leave the secret away. Then you will be prompted for thesecret whenever buildout is run::Example com realm, http://www.example.com, usernameNote that basic auth also works with any recipe usingzc.buildout.download (e.g. hexagonit.recipe.download) because thisextension also overwrites the url opener of zc.buildout.Github Private Downloads========================Private downloads on http://github.com/ require authorization to download.The previous token-based authentication system based on the v2 API (seehttp://github.com/blog/170-token-authentication) is no longer supported byGitHub as of June 1 2012; You must now request a v3 API token and use thatinstead.Requesting a new API token can be done in one line using ``curl`` (pleasesubstitute your own github username and password):curl -s -X POST -d '{"scopes": ["repo"], "note": "my API token"}' \https://${user}:${pass}@api.github.com/authorizations | grep tokenNow set the value of github.token to the hash returned from the command above:git config --global github.accesstoken ${token}Note that the v3 API does not require your github username to work, and canbe removed from your configuration if you wish.For details on managing authorization GitHub's OAuth tokens, see the APIdocumentation: http://developer.github.com/v3/oauth/#oauth-authorizations-apiURL to download a tag or branch::https://api.github.com/repos/<gituser>/<repos>/tarball/masterURL to downlad a "download"::https://github.com/downloads/<gituser>/<repos>/<name>As some eggs on PyPi also use public Github download URLs you may want towhitelist the repos that authentication is required for as Github willreturn a 401 error code even for public repositories if the wrong authdetails are provided.To do this just list each repo in the format `<gituser>/<repos>` one perline in the buildout config `github-repos`::[buildout]extensions = p01.buildouthttpgithub-repos = p01/reposbitly/asyncmongoCredits=======Thanks to lovely systems for development and Tarek Ziade, Kevin Williams,Wesley Mason for bugfixes and extensions.====================Handler Installation====================By default the install function looks for the password file at~/.buildout/.httpauth and installs a basic auth opener.It does not fail if the file cannot be found.>>> import os>>> from p01.buildouthttp.buildouthttp import install>>> install()We can supply the path to the file for testing.>>> install(pwd_path='a')If the file cannot be parsed an exception is raised.>>> fp = os.path.join(tmp,'pwd.txt')>>> import os>>> f = open(fp, 'w')>>> _ = f.write('The realm,https://example.com/ something')>>> f.close()>>> install(pwd_path=fp)Traceback (most recent call last):...RuntimeError: Authentication file cannot be parsed ...pwd.txt:1Some working examples.>>> f = open(fp, 'w')>>> _ = f.write('The realm,https://example.com/,username,password')>>> f.close()>>> install(pwd_path=fp)>>> f = open(fp, 'w')>>> _ = f.write('The realm,https://example.com/,username,password\n\n\n')>>> f.close()>>> install(pwd_path=fp)>>> f = open(fp, 'w')>>> _ = f.write('')>>> f.close()>>> install(pwd_path=fp)Now let's try with the ``.httpauth`` file in the buildout directory.>>> buildout_dir = os.path.join(tmp, 'test-buildout')>>> os.mkdir(buildout_dir)>>> buildout = {'buildout': {'directory': buildout_dir}}>>> install(buildout=buildout)>>> buildout_fp = os.path.join(buildout_dir, '.httpauth')>>> f = open(buildout_fp, 'w')>>> _ = f.write('The realm,https://example.com/ not valid')>>> f.close()>>> install(buildout=buildout)Traceback (most recent call last):...RuntimeError: Authentication file cannot be parsed ...None:1>>> f = open(buildout_fp, 'w')>>> _ = f.write('The realm,https://example.com/,username,password')>>> f.close()>>> install(buildout=buildout)Then with the file passed in and the file from the buildout directory.>>> f = open(fp, 'w')>>> _ = f.write('The realm,https://example.com/,username,password')>>> f.close()>>> install(buildout=buildout, pwd_path=fp)unload externsion:>>> from p01.buildouthttp.buildouthttp import unload>>> unload()=======CHANGES=======1.0.1 (2015-11-27)------------------- bugfix: fix url opener setup1.0.0 (2015-11-23)------------------- fix url handling troubles based on python 2.7.10 and zc.buildout > 2.2- initial copy of lovely.buildouthttp