1
# -*- coding: utf-8 -*-
2
# Moovida - Home multimedia server
3
# Copyright (C) 2007-2009 Fluendo Embedded S.L. (www.fluendo.com).
6
# This file is available under one of two license agreements.
8
# This file is licensed under the GPL version 3.
9
# See "LICENSE.GPL" in the root of this distribution including a special
10
# exception to use Moovida with Fluendo's plugins.
12
# The GPL part of Moovida is also available under a commercial licensing
13
# agreement from Fluendo.
14
# See "LICENSE.Moovida" in the root directory of this distribution package
15
# for details on that license.
17
# Author: Philippe Normand <philippe@fluendo.com>
21
def generate_basic_auth_headers(username, password):
22
""" Generate HTTP Basic Authentication headers given a username
23
and a password. This is implemented in respect with RFC 2617.
25
@param username: user id to use for the authentication against the server
26
@type username: C{str}
27
@param password: password to use during the authentication
28
@type password: C{str}
31
challenge = base64.b64encode("%s:%s" % (username, password))
32
headers = {"Authorization": ["Basic %s" % challenge]}