summaryrefslogtreecommitdiff
path: root/macaroonbakery/checkers
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2017-12-12 15:20:49 +0000
committerColin Watson <cjwatson@debian.org>2017-12-12 15:20:49 +0000
commit9e4403035a9953c99117083e6373ae3c441a76b5 (patch)
treed91b137df6767bfb8cb72de6b9fd21efb0c3dee4 /macaroonbakery/checkers
parent949b7072cabce0daed6c94993ad44c8ea8648dbd (diff)
Import py-macaroon-bakery_1.1.0.orig.tar.gz
Diffstat (limited to 'macaroonbakery/checkers')
-rw-r--r--macaroonbakery/checkers/__init__.py18
-rw-r--r--macaroonbakery/checkers/_auth_context.py (renamed from macaroonbakery/checkers/auth_context.py)0
-rw-r--r--macaroonbakery/checkers/_caveat.py (renamed from macaroonbakery/checkers/caveat.py)11
-rw-r--r--macaroonbakery/checkers/_checkers.py (renamed from macaroonbakery/checkers/checkers.py)23
-rw-r--r--macaroonbakery/checkers/_conditions.py (renamed from macaroonbakery/checkers/conditions.py)0
-rw-r--r--macaroonbakery/checkers/_declared.py (renamed from macaroonbakery/checkers/declared.py)12
-rw-r--r--macaroonbakery/checkers/_namespace.py (renamed from macaroonbakery/checkers/namespace.py)4
-rw-r--r--macaroonbakery/checkers/_operation.py (renamed from macaroonbakery/checkers/operation.py)2
-rw-r--r--macaroonbakery/checkers/_time.py (renamed from macaroonbakery/checkers/time.py)14
-rw-r--r--macaroonbakery/checkers/_utils.py (renamed from macaroonbakery/checkers/utils.py)0
10 files changed, 46 insertions, 38 deletions
diff --git a/macaroonbakery/checkers/__init__.py b/macaroonbakery/checkers/__init__.py
index 25c6b7d..b3ea466 100644
--- a/macaroonbakery/checkers/__init__.py
+++ b/macaroonbakery/checkers/__init__.py
@@ -1,6 +1,6 @@
# Copyright 2017 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
-from macaroonbakery.checkers.conditions import (
+from ._conditions import (
STD_NAMESPACE,
COND_DECLARED,
COND_TIME_BEFORE,
@@ -9,7 +9,7 @@ from macaroonbakery.checkers.conditions import (
COND_DENY,
COND_NEED_DECLARED,
)
-from macaroonbakery.checkers.caveat import (
+from ._caveat import (
allow_caveat,
deny_caveat,
declared_caveat,
@@ -17,35 +17,35 @@ from macaroonbakery.checkers.caveat import (
time_before_caveat,
Caveat,
)
-from macaroonbakery.checkers.declared import (
+from ._declared import (
context_with_declared,
infer_declared,
infer_declared_from_conditions,
need_declared_caveat,
)
-from macaroonbakery.checkers.operation import (
+from ._operation import (
context_with_operations,
)
-from macaroonbakery.checkers.namespace import (
+from ._namespace import (
Namespace,
deserialize_namespace
)
-from macaroonbakery.checkers.time import (
+from ._time import (
context_with_clock,
expiry_time,
macaroons_expiry_time,
)
-from macaroonbakery.checkers.checkers import (
+from ._checkers import (
Checker,
CheckerInfo,
RegisterError,
)
-from macaroonbakery.checkers.auth_context import (
+from ._auth_context import (
AuthContext,
ContextKey,
)
-from macaroonbakery.checkers.utils import (
+from ._utils import (
condition_with_prefix,
)
diff --git a/macaroonbakery/checkers/auth_context.py b/macaroonbakery/checkers/_auth_context.py
index dceb015..dceb015 100644
--- a/macaroonbakery/checkers/auth_context.py
+++ b/macaroonbakery/checkers/_auth_context.py
diff --git a/macaroonbakery/checkers/caveat.py b/macaroonbakery/checkers/_caveat.py
index a1e564e..5732f43 100644
--- a/macaroonbakery/checkers/caveat.py
+++ b/macaroonbakery/checkers/_caveat.py
@@ -3,10 +3,13 @@
import collections
import pyrfc3339
-
-from macaroonbakery.checkers.conditions import (
- STD_NAMESPACE, COND_TIME_BEFORE, COND_ERROR, COND_DENY, COND_ALLOW,
- COND_DECLARED
+from ._conditions import (
+ COND_ALLOW,
+ COND_DECLARED,
+ COND_DENY,
+ COND_ERROR,
+ COND_TIME_BEFORE,
+ STD_NAMESPACE,
)
diff --git a/macaroonbakery/checkers/checkers.py b/macaroonbakery/checkers/_checkers.py
index 776b50b..71cb56f 100644
--- a/macaroonbakery/checkers/checkers.py
+++ b/macaroonbakery/checkers/_checkers.py
@@ -6,17 +6,20 @@ from datetime import datetime
import pyrfc3339
import pytz
-
-from macaroonbakery.checkers.declared import DECLARED_KEY
-from macaroonbakery.checkers.time import TIME_KEY
-from macaroonbakery.checkers.operation import OP_KEY
-from macaroonbakery.checkers.namespace import Namespace
-from macaroonbakery.checkers.caveat import parse_caveat
-from macaroonbakery.checkers.conditions import (
- STD_NAMESPACE, COND_DECLARED, COND_ALLOW, COND_DENY, COND_ERROR,
- COND_TIME_BEFORE
+from ._caveat import parse_caveat
+from ._conditions import (
+ COND_ALLOW,
+ COND_DECLARED,
+ COND_DENY,
+ COND_ERROR,
+ COND_TIME_BEFORE,
+ STD_NAMESPACE,
)
-from macaroonbakery.checkers.utils import condition_with_prefix
+from ._declared import DECLARED_KEY
+from ._namespace import Namespace
+from ._operation import OP_KEY
+from ._time import TIME_KEY
+from ._utils import condition_with_prefix
class RegisterError(Exception):
diff --git a/macaroonbakery/checkers/conditions.py b/macaroonbakery/checkers/_conditions.py
index 74e863e..74e863e 100644
--- a/macaroonbakery/checkers/conditions.py
+++ b/macaroonbakery/checkers/_conditions.py
diff --git a/macaroonbakery/checkers/declared.py b/macaroonbakery/checkers/_declared.py
index 78a6181..ae4f95b 100644
--- a/macaroonbakery/checkers/declared.py
+++ b/macaroonbakery/checkers/_declared.py
@@ -1,11 +1,13 @@
# Copyright 2017 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
-from macaroonbakery.checkers.namespace import Namespace
-from macaroonbakery.checkers.caveat import parse_caveat, Caveat, error_caveat
-from macaroonbakery.checkers.conditions import (
- COND_DECLARED, COND_NEED_DECLARED, STD_NAMESPACE
+from ._auth_context import ContextKey
+from ._caveat import Caveat, error_caveat, parse_caveat
+from ._conditions import (
+ COND_DECLARED,
+ COND_NEED_DECLARED,
+ STD_NAMESPACE,
)
-from macaroonbakery.checkers.auth_context import ContextKey
+from ._namespace import Namespace
DECLARED_KEY = ContextKey('declared-key')
diff --git a/macaroonbakery/checkers/namespace.py b/macaroonbakery/checkers/_namespace.py
index 31e8801..6c3b1e3 100644
--- a/macaroonbakery/checkers/namespace.py
+++ b/macaroonbakery/checkers/_namespace.py
@@ -2,8 +2,8 @@
# Licensed under the LGPLv3, see LICENCE file for details.
import collections
-from macaroonbakery.checkers.utils import condition_with_prefix
-from macaroonbakery.checkers.caveat import error_caveat
+from ._caveat import error_caveat
+from ._utils import condition_with_prefix
class Namespace:
diff --git a/macaroonbakery/checkers/operation.py b/macaroonbakery/checkers/_operation.py
index a3b3805..56b267a 100644
--- a/macaroonbakery/checkers/operation.py
+++ b/macaroonbakery/checkers/_operation.py
@@ -1,6 +1,6 @@
# Copyright 2017 Canonical Ltd.
# Licensed under the LGPLv3, see LICENCE file for details.
-from macaroonbakery.checkers.auth_context import ContextKey
+from ._auth_context import ContextKey
OP_KEY = ContextKey('op-key')
diff --git a/macaroonbakery/checkers/time.py b/macaroonbakery/checkers/_time.py
index 0b52131..2ae1d89 100644
--- a/macaroonbakery/checkers/time.py
+++ b/macaroonbakery/checkers/_time.py
@@ -2,12 +2,10 @@
# Licensed under the LGPLv3, see LICENCE file for details.
import pyrfc3339
-
-from macaroonbakery.checkers.auth_context import ContextKey
-from macaroonbakery.checkers.conditions import COND_TIME_BEFORE, STD_NAMESPACE
-from macaroonbakery.checkers.utils import condition_with_prefix
-from macaroonbakery.checkers.caveat import parse_caveat
-
+from ._auth_context import ContextKey
+from ._caveat import parse_caveat
+from ._conditions import COND_TIME_BEFORE, STD_NAMESPACE
+from ._utils import condition_with_prefix
TIME_KEY = ContextKey('time-key')
@@ -54,12 +52,14 @@ def expiry_time(ns, cavs):
prefix, COND_TIME_BEFORE)
t = None
for cav in cavs:
+ if not cav.first_party():
+ continue
cav = cav.caveat_id_bytes.decode('utf-8')
name, rest = parse_caveat(cav)
if name != time_before_cond:
continue
try:
- et = pyrfc3339.parse(rest)
+ et = pyrfc3339.parse(rest, utc=True).replace(tzinfo=None)
if t is None or et < t:
t = et
except ValueError:
diff --git a/macaroonbakery/checkers/utils.py b/macaroonbakery/checkers/_utils.py
index 925e8c7..925e8c7 100644
--- a/macaroonbakery/checkers/utils.py
+++ b/macaroonbakery/checkers/_utils.py