summary refs log tree commit diff
path: root/scripts-dev/dump_macaroon.py
blob: 22b30fa78e43d7599f329338969203f42cede85b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python2

from __future__ import print_function

import sys

import pymacaroons

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(str(e))