diff options
Diffstat (limited to 'moon_wrapper')
-rw-r--r-- | moon_wrapper/Dockerfile | 8 | ||||
-rw-r--r-- | moon_wrapper/README.md | 3 | ||||
-rw-r--r-- | moon_wrapper/moon_wrapper/api/oslowrapper.py (renamed from moon_wrapper/moon_wrapper/api/wrapper.py) | 13 | ||||
-rw-r--r-- | moon_wrapper/moon_wrapper/http_server.py | 15 | ||||
-rw-r--r-- | moon_wrapper/moon_wrapper/server.py | 5 |
5 files changed, 17 insertions, 27 deletions
diff --git a/moon_wrapper/Dockerfile b/moon_wrapper/Dockerfile index 55e7208d..77ffaee9 100644 --- a/moon_wrapper/Dockerfile +++ b/moon_wrapper/Dockerfile @@ -1,12 +1,8 @@ -FROM ubuntu:latest - -RUN apt update && apt install python3.5 python3-pip -y -RUN pip3 install pip --upgrade +FROM python:3 ADD . /root WORKDIR /root/ -RUN pip3 install -r requirements.txt --upgrade -RUN pip3 install /root/dist/* --upgrade +RUN pip3 install -r requirements.txt RUN pip3 install . CMD ["python3", "-m", "moon_wrapper"] diff --git a/moon_wrapper/README.md b/moon_wrapper/README.md index 4e8fd05c..cdd043a9 100644 --- a/moon_wrapper/README.md +++ b/moon_wrapper/README.md @@ -1,5 +1,4 @@ -Wrapper module for the Moon project -=================================== +# moon_wrapper This package contains the core module for the Moon project It is designed to provide authorization features to all OpenStack components. diff --git a/moon_wrapper/moon_wrapper/api/wrapper.py b/moon_wrapper/moon_wrapper/api/oslowrapper.py index e1ce783a..a422ee42 100644 --- a/moon_wrapper/moon_wrapper/api/wrapper.py +++ b/moon_wrapper/moon_wrapper/api/oslowrapper.py @@ -19,14 +19,14 @@ __version__ = "0.1.0" LOG = logging.getLogger("moon.wrapper.api." + __name__) -class Wrapper(Resource): +class OsloWrapper(Resource): """ Endpoint for authz requests """ __urls__ = ( - "/authz", - "/authz/", + "/authz/oslo", + "/authz/oslo/", ) def __init__(self, **kwargs): @@ -34,10 +34,6 @@ class Wrapper(Resource): self.CACHE = kwargs.get("cache", {}) self.TIMEOUT = 5 - # def get(self): - # LOG.info("GET") - # return self.manage_data() - def post(self): LOG.debug("POST {}".format(request.form)) response = flask.make_response("False") @@ -101,6 +97,7 @@ class Wrapper(Resource): rule = data.get('rule', "") _subject = self.__get_subject(target, credentials) _object = self.__get_object(target, credentials) + _action = rule _project_id = self.__get_project_id(target, credentials) LOG.debug("POST with args project={} / " "subject={} - object={} - action={}".format( @@ -112,7 +109,7 @@ class Wrapper(Resource): _project_id, _subject, _object, - rule + _action )) LOG.debug("Get interface {}".format(req.text)) if req.status_code == 200: diff --git a/moon_wrapper/moon_wrapper/http_server.py b/moon_wrapper/moon_wrapper/http_server.py index 1b429bc5..8027a0d3 100644 --- a/moon_wrapper/moon_wrapper/http_server.py +++ b/moon_wrapper/moon_wrapper/http_server.py @@ -8,15 +8,19 @@ from flask_restful import Resource, Api import logging from moon_wrapper import __version__ from moon_wrapper.api.generic import Status, Logs, API -from moon_wrapper.api.wrapper import Wrapper +from moon_wrapper.api.oslowrapper import OsloWrapper from python_moonutilities.cache import Cache from python_moonutilities import configuration, exceptions -logger = logging.getLogger("moon.wrapper.http") +logger = logging.getLogger("moon.wrapper.http_server") CACHE = Cache() +__API__ = ( + Status, Logs, API + ) + class Server: """Base class for HTTP server""" @@ -61,10 +65,6 @@ class Server: def run(self): raise NotImplementedError() -__API__ = ( - Status, Logs, API - ) - class Root(Resource): """ @@ -127,7 +127,7 @@ class HTTPServer(Server): for api in __API__: self.api.add_resource(api, *api.__urls__) - self.api.add_resource(Wrapper, *Wrapper.__urls__, + self.api.add_resource(OsloWrapper, *OsloWrapper.__urls__, resource_class_kwargs={ "orchestrator_url": self.orchestrator_url, "cache": CACHE, @@ -136,5 +136,4 @@ class HTTPServer(Server): def run(self): self.app.run(host=self._host, port=self._port) # nosec - # self.app.run(debug=True, host=self._host, port=self._port) # nosec diff --git a/moon_wrapper/moon_wrapper/server.py b/moon_wrapper/moon_wrapper/server.py index 2f236c4f..280fdb68 100644 --- a/moon_wrapper/moon_wrapper/server.py +++ b/moon_wrapper/moon_wrapper/server.py @@ -7,7 +7,7 @@ import logging from python_moonutilities import configuration, exceptions from moon_wrapper.http_server import HTTPServer -LOG = logging.getLogger("moon.wrapper") +LOG = logging.getLogger("moon.wrapper.server") def main(): @@ -24,8 +24,7 @@ def main(): port = 80 configuration.add_component(uuid="wrapper", name=hostname, port=port, bind=bind) LOG.info("Starting server with IP {} on port {} bind to {}".format(hostname, port, bind)) - server = HTTPServer(host=bind, port=port) - return server + return HTTPServer(host=bind, port=port) if __name__ == '__main__': |