summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2016-02-03 11:27:39 +0000
committerDaniel Wagner-Hall <daniel@matrix.org>2016-02-03 11:27:39 +0000
commit5f280837a6757c3e9fe226c3fac35409c23d3967 (patch)
treecf616d91ab6d73702829072070366f4d02a171a2
parentMerge pull request #553 from matrix-org/daniel/accesstokenlogging (diff)
downloadsynapse-5f280837a6757c3e9fe226c3fac35409c23d3967.tar.xz
Add macaroon inspection script
Diffstat (limited to '')
-rwxr-xr-xscripts-dev/dump_macaroon.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts-dev/dump_macaroon.py b/scripts-dev/dump_macaroon.py
new file mode 100755
index 0000000000..6e45be75d6
--- /dev/null
+++ b/scripts-dev/dump_macaroon.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python2
+
+import pymacaroons
+import sys
+
+if len(sys.argv) == 1:
+    sys.stderr.write("usage: %s macaroon [key]\n" % (sys.argv[0],))
+    sys.exit(1)
+
+macaroon_string = sys.argv[1]
+key = sys.argv[2] if len(sys.argv) > 2 else None
+
+macaroon = pymacaroons.Macaroon.deserialize(macaroon_string)
+print macaroon.inspect()
+
+print ""
+
+verifier = pymacaroons.Verifier()
+verifier.satisfy_general(lambda c: True)
+try:
+    verifier.verify(macaroon, key)
+    print "Signature is correct"
+except Exception as e:
+    print e.message