1
0

dump_macaroon.py 572 B

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