Ejemplo n.º 1
0
 def post(self, res_id):
     """ Creates a new session and returns its ID
     # POST http://<proxy>/sessions/
     # Request Headers: { Authorization: <signed_ticket> }
     # Response Headers: { 'session_id': session_id }
     """
     session_id = auth.get_session_attribute(self.request, auth.SESSION_ID)
     response = server.response(200)
     response.headers[auth.SESSION_ID] = session_id
     return response
Ejemplo n.º 2
0
    def get_resource_id(self, request):
        resource_id = request.path_info_pop()
        if request.path_info:
            # No extra url path allowed!
            raise exc.HTTPBadRequest("Invalid resource path")

        # The requested image resource must match the one in the ticket
        try:
            uuid.UUID(resource_id)
        except ValueError:
            raise exc.HTTPBadRequest(
                "Invalid format for requested resource or no resource specified"
            )
        if (resource_id != auth.get_session_attribute(
                request, auth.SESSION_TRANSFER_TICKET)):
            raise exc.HTTPBadRequest(
                "Requested resource must match transfer ticket")
        return resource_id
Ejemplo n.º 3
0
 def get_imaged_url(self, request):
     uri = auth.get_session_attribute(request, auth.SESSION_IMAGED_HOST_URI)
     ticket = auth.get_session_attribute(request,
                                         auth.SESSION_TRANSFER_TICKET)
     return "{}/images/{}".format(uri, ticket)