Skip to content

Commit

Permalink
[FIX] Work around non RFC compliant 'www-authenticate' header
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Sep 25, 2017
1 parent e11e66b commit 2fe8d3f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def read(fname):
version = version,
install_requires = [
'iso8601',
'httplib2'
'httplib2',
'wrapt',
],
author = 'Apache Chemistry Project',
author_email = 'dev@chemistry.apache.org',
Expand Down
23 changes: 23 additions & 0 deletions src/cmislib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@
# specific language governing permissions and limitations
# under the License.
#

"""
Patch httplib2 before the its import to work around a bug into alfresco
https://issues.alfresco.com/jira/browse/MNT-15819
"""
import wrapt
@wrapt.patch_function_wrapper('httplib2', '_parse_www_authenticate')
def wrapper(wrapped, instance, args, kwargs):
headers = kwargs.get('headers') or args[0]
headername = kwargs.get('headername') or args[1]
if headername == 'www-authenticate' and headers.has_key(headername):
authenticate = headers[headername].strip()
if len(authenticate.split(" ")) < 2:
# A BUG into alfresco generates non RFC compliant
# 'www-authenticate' header
# https://issues.alfresco.com/jira/browse/MNT-15819
# work around this bug and but force Basic auth into the supported
# authentication
authenticate = authenticate + ' , Basic realm=""'
headers[headername] = authenticate
return wrapped(headers, headername)
return wrapped(*args, **kwargs)

"""
Define package contents so that they are easy to import.
"""
Expand Down

0 comments on commit 2fe8d3f

Please sign in to comment.