-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathview-macaroon
More file actions
executable file
·34 lines (31 loc) · 1.15 KB
/
Copy pathview-macaroon
File metadata and controls
executable file
·34 lines (31 loc) · 1.15 KB
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
28
29
30
31
32
33
34
#!/usr/bin/env python
# This script decodes (or "deserializes") and prints a macaroon.
# It uses pymacaroons, which can be installed on Centos 7 with:
# yum install python2-pip
# pip install pymacaroons
import sys, os, re
from pymacaroons import Macaroon
if len(sys.argv) > 1:
for arg in sys.argv[1:]:
# Is this argument a filename or a macaroon?
if os.path.isfile(arg):
# Filename. Treat the contents as the macaroon.
with open(arg, 'r') as file:
for line in file:
# Does this line contain a macaroon?
token = re.search("MDA\S*", line)
if token:
m = Macaroon.deserialize (token.group())
print(m.inspect())
else:
# A literal macaroon.
m = Macaroon.deserialize(arg)
print(m.inspect())
else:
# No arguments provided, let's try to read from stdin.
for line in sys.stdin:
# Does this line contain a macaroon?
token = re.search("MDA\S*", line)
if token:
m = Macaroon.deserialize (token.group())
print(m.inspect())