Beispiel #1
0
    def prepare(self):

        app_log.debug("Incoming request from %s: %s",
                      self.request.remote_ip,
                      self.request)

        if settings['auth_enabled'] and self.request.method != "OPTIONS":
            is_authenticated = userauth.is_user_authenticated(self)
        else:
            is_authenticated = True

        if not is_authenticated:
            self.set_status(httplib.UNAUTHORIZED)
            self.set_header("Link", "/login")
            self.finish()
        else:
            self.resource_path = parse_url_path(self.request.path,
                                                self.schema,
                                                self.idl,
                                                self.request.method)

            if self.resource_path is None:
                self.set_status(httplib.NOT_FOUND)
                self.finish()
            else:
                #If Match support
                match = self.process_if_match()
                if not match:
                    self.finish()
Beispiel #2
0
def check_authenticated(req_handler, req_method):
    if settings['auth_enabled'] and req_method != REQUEST_TYPE_OPTIONS:
        is_authenticated = userauth.is_user_authenticated(req_handler)
    else:
        is_authenticated = True

    if not is_authenticated:
        raise NotAuthenticated
Beispiel #3
0
    def get(self):

        is_authenticated = userauth.is_user_authenticated(self)
        if not is_authenticated:
            self.set_status(httplib.UNAUTHORIZED)
            self.set_header("Link", "/login")
        else:
            self.set_status(httplib.OK)

        self.finish()
Beispiel #4
0
    def get(self):
        try:
            app_log.debug("Executing Login GET...")

            is_authenticated = userauth.is_user_authenticated(self)
            if not is_authenticated:
                raise AuthenticationFailed
            else:
                self.set_status(httplib.OK)

        except APIException as e:
            self.on_exception(e)

        except Exception as e:
            self.on_exception(e)

        self.finish()
Beispiel #5
0
    def get(self):
        try:
            app_log.debug("Executing Login GET...")

            is_authenticated = userauth.is_user_authenticated(self)
            if not is_authenticated:
                raise AuthenticationFailed
            else:
                self.set_status(httplib.OK)

        except APIException as e:
            self.on_exception(e)

        except Exception as e:
            self.on_exception(e)

        self.finish()
Beispiel #6
0
    def prepare(self):
        app_log.debug("Incoming request from %s: %s",
                      self.request.remote_ip,
                      self.request)

        if settings['auth_enabled'] and self.request.method != "OPTIONS":
            is_authenticated = userauth.is_user_authenticated(self)
        else:
            is_authenticated = True

        if not is_authenticated:
            self.set_status(httplib.UNAUTHORIZED)
            self.set_header("Link", "/login")
            self.finish()
        else:
            self.current_user = {}
            self.current_user["username"] = self.get_current_user()
Beispiel #7
0
    def prepare(self):
        try:
            redirect_http_to_https(self)

            app_log.debug("Incoming request from %s: %s",
                          self.request.remote_ip,
                          self.request)

            if settings['auth_enabled'] and self.request.method != "OPTIONS":
                is_authenticated = userauth.is_user_authenticated(self)
            else:
                is_authenticated = True

            if not is_authenticated:
                raise NotAuthenticated

            # Check user's permissions
            self.check_method_permission()

            sort = get_query_arg(REST_QUERY_PARAM_SORTING,
                                 self.request.query_arguments)

            depth = get_query_arg(REST_QUERY_PARAM_DEPTH,
                                  self.request.query_arguments)

            columns = get_query_arg(REST_QUERY_PARAM_COLUMNS,
                                    self.request.query_arguments)

            if self.request.method != REQUEST_TYPE_READ \
               and (depth is not None or columns is not None or
                    sort is not None):
                raise ParameterNotAllowed("Arguments %s, %s and %s "
                                          "are only allowed in %s" %
                                          (REST_QUERY_PARAM_SORTING,
                                           REST_QUERY_PARAM_DEPTH,
                                           REST_QUERY_PARAM_COLUMNS,
                                           REQUEST_TYPE_READ))

        except APIException as e:
            self.on_exception(e)
            self.finish()

        except Exception, e:
            self.on_exception(e)
            self.finish()
Beispiel #8
0
    def prepare(self):
        if settings['auth_enabled']:
            is_authenticated = userauth.is_user_authenticated(self)
        else:
            is_authenticated = True

        if not is_authenticated:
            self.set_status(httplib.UNAUTHORIZED)
            self.set_header("Link", "/login")
            self.finish()
        else:
            self.request_type = self.get_argument('type', 'running')
            app_log.debug('request type: %s', self.request_type)

            if self.request_type == 'running':
                self.config_util = runconfig.RunConfigUtil(self.idl,
                                                           self.schema)
            elif self.request_type == 'startup':
                self.config_util = startupconfig.StartupConfigUtil()
            else:
                self.set_status(httplib.BAD_REQUEST)
                self.finish()