summaryrefslogtreecommitdiffstats
path: root/custodia/httpd/server.py
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-04-07 22:44:54 -0400
committerSimo Sorce <simo@redhat.com>2015-04-08 00:19:20 -0400
commitf5e002a3d066ed29e5cf4154b6dfa6fd1732785b (patch)
tree153344078cecb2fd82e6d089a8e8360b28d43d4c /custodia/httpd/server.py
parent0c8c416289514889ec095c203880a8ce1e4c23d4 (diff)
downloadcustodia-f5e002a3d066ed29e5cf4154b6dfa6fd1732785b.tar.gz
custodia-f5e002a3d066ed29e5cf4154b6dfa6fd1732785b.tar.xz
custodia-f5e002a3d066ed29e5cf4154b6dfa6fd1732785b.zip
Add basic framework for authorization plugins
Diffstat (limited to 'custodia/httpd/server.py')
-rw-r--r--custodia/httpd/server.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/custodia/httpd/server.py b/custodia/httpd/server.py
index a5e59a9..9ae3f68 100644
--- a/custodia/httpd/server.py
+++ b/custodia/httpd/server.py
@@ -62,9 +62,15 @@ class ForkingLocalHTTPServer(ForkingMixIn, UnixStreamServer):
can add attributes to the request object for use of authorization or
other plugins.
- Once authentication is successful the pipeline will parse the path
- component and find the consumer plugin that handles the provided path
- walking up the path component by component until a consumer is found.
+ When authorization is performed and positive result will cause the
+ operation to be accepted and any negative result will cause it to fail.
+ If no authorization plugin returns a positive result a 403 error is
+ returned.
+
+ Once authentication and authorization are successful the pipeline will
+ parse the path component and find the consumer plugin that handles the
+ provided path walking up the path component by component until a
+ consumer is found.
Paths are walked up from the leaf to the root, so if two consumers hang
on the same tree, the one closer to the leaf will be used. If there is
@@ -105,6 +111,17 @@ class ForkingLocalHTTPServer(ForkingMixIn, UnixStreamServer):
if valid_once is not True:
raise HTTPError(403)
+ # auhz framework here
+ authzers = self.config.get('authorizers')
+ if authzers is None:
+ raise HTTPError(403)
+ for authz in authzers:
+ valid = authzers[authz].handle(request)
+ if valid is not None:
+ break
+ if valid is not True:
+ raise HTTPError(403)
+
# Select consumer
path = request.get('path', '')
if not os.path.isabs(path):