summaryrefslogtreecommitdiff
path: root/macaroonbakery/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'macaroonbakery/utils.py')
-rw-r--r--macaroonbakery/utils.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/macaroonbakery/utils.py b/macaroonbakery/utils.py
index c747ad3..3b5550b 100644
--- a/macaroonbakery/utils.py
+++ b/macaroonbakery/utils.py
@@ -1,13 +1,11 @@
# Copyright 2017 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
-
import base64
import json
import webbrowser
from pymacaroons import Macaroon
-
-from macaroonbakery import json_serializer
+from pymacaroons.serializers import json_serializer
def deserialize(json_macaroon):
@@ -52,6 +50,18 @@ def remove_base64_padding(b):
return b.rstrip(b'=')
+def raw_b64decode(s):
+ '''Base64 decode with added padding with urlsafe or not.
+
+ @param s string decode
+ @return bytes decoded
+ '''
+ if '_' or '-' in s:
+ return raw_urlsafe_b64decode(s)
+ else:
+ return base64.b64decode(add_base64_padding(s))
+
+
def raw_urlsafe_b64decode(s):
'''Base64 decode with added padding and convertion to bytes.