aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/federation/tools/request.py
diff options
context:
space:
mode:
authorxray7224 <jessica@megworld.co.uk>2013-07-18 19:15:05 +0100
committerxray7224 <jessica@megworld.co.uk>2013-07-18 19:15:05 +0100
commit89d5b44e0aee5845f816a89a9f8b3364940daea3 (patch)
treecfb47e5edc170d33c407502d4f7caec2b1c68f26 /mediagoblin/federation/tools/request.py
parent86ba41688332e3f71779f76c486889a7a099fa91 (diff)
downloadmediagoblin-89d5b44e0aee5845f816a89a9f8b3364940daea3.tar.lz
mediagoblin-89d5b44e0aee5845f816a89a9f8b3364940daea3.tar.xz
mediagoblin-89d5b44e0aee5845f816a89a9f8b3364940daea3.zip
Adds test for request_tokens
Diffstat (limited to 'mediagoblin/federation/tools/request.py')
-rw-r--r--mediagoblin/federation/tools/request.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/mediagoblin/federation/tools/request.py b/mediagoblin/federation/tools/request.py
index 4f5be277..6e484bb6 100644
--- a/mediagoblin/federation/tools/request.py
+++ b/mediagoblin/federation/tools/request.py
@@ -14,14 +14,19 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import re
-
-# Regex for parsing Authorization string
-auth_header_re = re.compile('(\w+)[:=] ?"?(\w+)"?')
-
def decode_authorization_header(header):
""" Decodes a HTTP Authorization Header to python dictionary """
- authorization = header.get("Authorization", "")
- tokens = dict(auth_header_re.findall(authorization))
+ authorization = header.get("Authorization", "").lstrip(" ").lstrip("OAuth")
+ tokens = {}
+
+ for param in authorization.split(","):
+ key, value = param.split("=")
+
+ key = key.lstrip(" ")
+ value = value.lstrip(" ").lstrip('"')
+ value = value.rstrip(" ").rstrip('"')
+
+ tokens[key] = value
+
return tokens