dump_macaroon.py 531 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python2
  2. import pymacaroons
  3. import sys
  4. if len(sys.argv) == 1:
  5. sys.stderr.write("usage: %s macaroon [key]\n" % (sys.argv[0],))
  6. sys.exit(1)
  7. macaroon_string = sys.argv[1]
  8. key = sys.argv[2] if len(sys.argv) > 2 else None
  9. macaroon = pymacaroons.Macaroon.deserialize(macaroon_string)
  10. print macaroon.inspect()
  11. print ""
  12. verifier = pymacaroons.Verifier()
  13. verifier.satisfy_general(lambda c: True)
  14. try:
  15. verifier.verify(macaroon, key)
  16. print "Signature is correct"
  17. except Exception as e:
  18. print e.message