diff options
Diffstat (limited to 'macaroonbakery/checkers/_operation.py')
-rw-r--r-- | macaroonbakery/checkers/_operation.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/macaroonbakery/checkers/_operation.py b/macaroonbakery/checkers/_operation.py new file mode 100644 index 0000000..56b267a --- /dev/null +++ b/macaroonbakery/checkers/_operation.py @@ -0,0 +1,17 @@ +# Copyright 2017 Canonical Ltd. +# Licensed under the LGPLv3, see LICENCE file for details. +from ._auth_context import ContextKey + +OP_KEY = ContextKey('op-key') + + +def context_with_operations(ctx, ops): + ''' Returns a context(AuthContext) which is associated with all the given + operations (list of string). It will be based on the auth context + passed in as ctx. + + An allow caveat will succeed only if one of the allowed operations is in + ops; a deny caveat will succeed only if none of the denied operations are + in ops. + ''' + return ctx.with_value(OP_KEY, ops) |