1
0

dump_macaroon.py 533 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python2
  2. import sys
  3. import pymacaroons
  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(str(e))