initial auth module w/ httpbasic auth
authorKenneth Reitz <me@kennethreitz.com>
Sun, 23 Oct 2011 14:56:04 +0000 (10:56 -0400)
committerKenneth Reitz <me@kennethreitz.com>
Sun, 23 Oct 2011 14:56:04 +0000 (10:56 -0400)
requests/auth.py [new file with mode: 0644]

diff --git a/requests/auth.py b/requests/auth.py
new file mode 100644 (file)
index 0000000..900a048
--- /dev/null
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+"""
+requests.auth
+~~~~~~~~~~~~~
+
+This module contains the authentication handlers for Requests.
+"""
+
+from base64 import encodestring as base64
+
+def http_basic(r, username, password):
+    """Attaches HTTP Basic Authentication to the given Request object.
+    Arguments should be considered non-positional.
+
+    """
+
+    auth_s = base64('%s:%s' % (username, password)).replace('\n', '')
+    r.headers['Authorization'] = ('Basic %s' % auth_s)
+
+    return r
+
+
+def http_digest(r, username, password):
+    """Attaches HTTP Digest Authentication to the given Request object.
+    Arguments should be considered non-positional.
+    """
+
+    r.headers
\ No newline at end of file