2021-05-12 14:04:51 +00:00
|
|
|
#!/usr/bin/env python
|
2016-02-03 11:27:39 +00:00
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2018-10-20 00:16:55 +00:00
|
|
|
import pymacaroons
|
|
|
|
|
2016-02-03 11:27:39 +00:00
|
|
|
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)
|
2018-10-20 00:16:55 +00:00
|
|
|
print(macaroon.inspect())
|
2016-02-03 11:27:39 +00:00
|
|
|
|
2018-10-20 00:16:55 +00:00
|
|
|
print("")
|
2016-02-03 11:27:39 +00:00
|
|
|
|
|
|
|
verifier = pymacaroons.Verifier()
|
|
|
|
verifier.satisfy_general(lambda c: True)
|
|
|
|
try:
|
|
|
|
verifier.verify(macaroon, key)
|
2018-10-20 00:16:55 +00:00
|
|
|
print("Signature is correct")
|
2016-02-03 11:27:39 +00:00
|
|
|
except Exception as e:
|
2018-10-20 00:16:55 +00:00
|
|
|
print(str(e))
|