예제 #1
2
 def add_rules(self):
     app.add_url_rule('/main/<collection_name>', "main", login_required(self.main), methods=['get'])
     app.add_url_rule('/load_files/<collection_name>', "load_files",
                      login_required(self.load_files), methods=['get', "post"])
     app.add_url_rule('/delete_collection/<collection_name>', "delete_collection",
                      login_required(self.delete_collection), methods=['post'])
     app.add_url_rule('/duplicate_collection', "duplicate_collection",
                      login_required(self.duplicate_collection), methods=['post', 'get'])
예제 #2
1
 def add_rules(self):
     app.add_url_rule('/reset_server/<user_manage_id>', "reset_server", login_required(self.reset_server),
                      methods=['get'])
     app.add_url_rule('/clear_user_containers/<user_manage_id>', "clear_user_containers",
                      login_required(self.clear_user_containers), methods=['get'])
     app.add_url_rule('/destroy_container/<container_id>', "kill_container",
                      login_required(self.kill_container), methods=['get'])
     app.add_url_rule('/container_logs/<container_id>', "container_logs",
                      login_required(self.container_logs), methods=['get'])
     app.add_url_rule('/refresh_container_table', "refresh_container_table",
                      login_required(self.refresh_container_table), methods=['get'])
예제 #3
0
 def init_app(self):
     self.login_manager.user_loader(self.load_user)
     self.app.route('/favicon.ico')(self.favicon)
     self.app.route('/')(self.index)
     self.app.route('/questions/<questionName>', methods=['GET', 'POST'])(login_required(self.question))
     self.app.route('/login', methods=['GET', 'POST'])(self.login)
     self.app.route('/logout')(login_required(self.logout))
예제 #4
0
 def add_rules(self):
     app.add_url_rule('/delete_user/<userid>',
                      "delete_user",
                      login_required(self.delete_user),
                      methods=['get', "post"])
     app.add_url_rule('/update_user_starter_tiles/<userid>',
                      "update_user_starter_tiles",
                      login_required(self.update_user_starter_tiles),
                      methods=['get', "post"])
     app.add_url_rule('/update_all_collections',
                      "update_all_collections",
                      login_required(self.update_all_collections),
                      methods=['get'])
예제 #5
0
 def add_rules(self):
     app.add_url_rule('/delete_project',
                      "delete_project",
                      login_required(self.delete_project),
                      methods=['post'])
     app.add_url_rule('/duplicate_project',
                      "duplicate_project",
                      login_required(self.duplicate_project),
                      methods=['get', 'post'])
     app.add_url_rule('/search_project_metadata',
                      "search_project_metadata",
                      login_required(self.search_project_metadata),
                      methods=['get', 'post'])
예제 #6
0
 def decorated_function(*args, **kwargs):
   if request.remote_addr == "91.121.177.171":
     return f(*args, **kwargs)
   elif not flask_login.current_user.is_authenticated() or int(flask_login.current_user.get_id()) != int(kwargs['userid']):
     return unauthorized()
   else:
     return flask_login.login_required(f)(*args, **kwargs)
예제 #7
0
def protect_views(app):
    for view_func in app.server.view_functions:
        if view_func.startswith(app.config['url_base_pathname']):
            app.server.view_functions[view_func] = login_required(
                app.server.view_functions[view_func])

    return app
예제 #8
0
def register_route(url, methods, func, login=True):
    '''注册路由'''
    logger.info(f"注册路由:{url},endpoint:{methods},func:{func.__name__}")
    if login:
        bp_main.route(url, methods=methods)(login_required(func))
    else:
        bp_main.route(url, methods=methods)(func)
예제 #9
0
 def wrapped(*args, **kwargs):
     if ('Authorization' not in request.headers):
         abort(401)
     response = login_required(f)(*args, **kwargs)
     if response.status_code == 302:
         abort(403)
     return response
예제 #10
0
def create_dash_kpi1(flask_app):

    dash_app = dash.Dash(server=flask_app,
                         name="Dashboard",
                         url_base_pathname=("/kpi1/"),
                         external_stylesheets=external_stylesheets)

    dash_app.layout = html.Div(
        children=[
            html.H1(children='Number of incidents - by priority'),
            html.Div(children='''
            How many incidents do we have and how severe are they?
        '''),
            dcc.Graph(
                id='kpi1',
                figure=px.bar(k1_fetch(),
                              x="Months",
                              y="Number of incidents",
                              color="Priority",
                              barmode="group"),
            )
        ],
        style={'font-family': ' Arial, Helvetica, sans-serif'})

    for view_function in dash_app.server.view_functions:
        if view_function.startswith(dash_app.config.url_base_pathname):
            dash_app.server.view_functions[view_function] = login_required(
                dash_app.server.view_functions[view_function])

    return dash_app
예제 #11
0
def register_dash_app(app, dash_app, *args):
    dash_app.init_app(app)

    if app.config['DEBUG']:
        dash_app.enable_dev_tools(debug=True)
    if dash_app.logger.hasHandlers():
        dash_app.logger.handlers.clear()

    if current_app.config['DEBUG']:
        app.logger.warning(
            "Debugging enabled. Skipping activation and login requirements for dash apps!"
        )

    for view_name, view_method in dash_app.server.view_functions.items():
        if view_name.startswith(dash_app.config['routes_pathname_prefix']):
            csrf.exempt(view_method)

            if not current_app.config['DEBUG']:
                if 'activation_required' in args:
                    app.logger.debug(
                        f"Enabling 'activation required' for view '{view_name}'."
                    )
                    dash_app.server.view_functions[
                        view_name] = activation_required(view_method)
                elif 'login_required' in args:
                    app.logger.debug(
                        f"Enabling 'login required' for view '{view_name}'.")
                    dash_app.server.view_functions[view_name] = login_required(
                        view_method)
예제 #12
0
def register_route(url, methods, func, login=True):
    '''注册路由'''
    logger.info("注册路由:{}".format(url))
    if login:
        main.route(url, methods=methods)(login_required(func))
    else:
        main.route(url, methods=methods)
예제 #13
0
def create_app(config_class=Config):
    app = Flask(__name__, instance_relative_config=False)
    app.config.from_object(config_class)

    with app.app_context():
        from app.main import bp as main_bp
        from app.auth import bp as auth_bp

        # importing blueprints
        app.register_blueprint(main_bp, url_prefix='/')
        app.register_blueprint(auth_bp, url_prefix='/')

        # importing dash app
        from app.dash_1 import dash_app
        app = dash_app.Add_Dash(app)

        # binding login to dash
        url_dash = dash_app.url_dash
        for view_func in app.view_functions:
            if view_func.startswith(url_dash):
                app.view_functions[view_func] = login_required(
                    app.view_functions[view_func])

    bootstrap.init_app(app)
    db.init_app(app)
    login.init_app(app)

    return app
예제 #14
0
        def decorator(function):
            @functools.wraps(function)
            def wrapper(*args, **kwargs):
                return callback(function, args, kwargs, (), {})

            wrapper._audit_permissions = handler, []
            return flask_login.login_required(wrapper)
예제 #15
0
def create_dash_kpi4(flask_app):
    dash_app = dash.Dash(server=flask_app,
                         name="Dashboard",
                         url_base_pathname=("/kpi4/"))

    dash_app.layout = html.Div(
        children=[
            html.H1(children='Backlog of incidents'),
            html.Div(children='''
            How many incidents do we have in our backlog?
        '''),
            dcc.Graph(id='kpi4',
                      figure=px.bar(k4_fetch(),
                                    x="Months",
                                    y="Number of incidents",
                                    barmode="group"))
        ],
        style={'font-family': ' Arial, Helvetica, sans-serif'})

    for view_function in dash_app.server.view_functions:
        if view_function.startswith(dash_app.config.url_base_pathname):
            dash_app.server.view_functions[view_function] = login_required(
                dash_app.server.view_functions[view_function])

    return dash_app
예제 #16
0
def create_dash_kpi2(flask_app):
    dash_app = dash.Dash(server=flask_app,
                         name="Dashboard",
                         url_base_pathname=("/kpi2/"))

    dash_app.layout = html.Div(
        children=[
            html.H1(children='KPI2'),
            html.Div(children='''
            Dash: A web application framework for Python.
        '''),
            dcc.Graph(id='example-graph',
                      figure=px.bar(k2_fetch(),
                                    x="Months",
                                    y="Number of incidents",
                                    barmode="group"))
        ],
        style={'font-family': ' Arial, Helvetica, sans-serif'})

    for view_function in dash_app.server.view_functions:
        if view_function.startswith(dash_app.config.url_base_pathname):
            dash_app.server.view_functions[view_function] = login_required(
                dash_app.server.view_functions[view_function])

    return dash_app
예제 #17
0
def download_file(filename):
    try:
        if filename == 'node.txt':
            # @login_required
            def send_nodef(filename):
                nodemcu_user = ast.literal_eval(current_user.nodemcu)['nodemcu_user']
                filename = os.path.join(current_app.root_path, Auth.UPLOAD_FOLDER, filename)
                f_write = os.path.join(current_app.root_path, Auth.UPLOAD_FOLDER, 'nodemcu_code.txt')
                # filename = safe_join(Auth.UPLOAD_FOLDER,filename)
                # f_write = safe_join(Auth.UPLOAD_FOLDER,'nodemcu_code.txt')
                f = open(filename, 'rt')
                f2 = open(f_write, 'wt')
                for line in f:
                    if '<NODEMCU_USER>' in line:
                        line = line.replace('<NODEMCU_USER>',nodemcu_user)
                    f2.write(line)
                f.close()
                f2.close()
                return send_from_directory(Auth.UPLOAD_FOLDER,filename='nodemcu_code.txt',attachment_filename='nodemcu_code.txt',as_attachment=True)
            send_nodef = login_required(send_nodef)
            return send_nodef(filename)
        else:
            return send_from_directory(Auth.UPLOAD_FOLDER,filename=filename,as_attachment=True)
    except Exception as e:
        return str(e)
예제 #18
0
def create_dash_kpi6(flask_app):
    dash_app = dash.Dash(server=flask_app,
                         name="Dashboard",
                         url_base_pathname=("/kpi6/"))

    dash_app.layout = html.Div(
        children=[
            html.H1(children='Monthly Availability of critical services'),
            html.Div(children='''
            How well are our most critical services available?
        '''),
            dcc.Graph(id='kpi6',
                      figure=px.bar(k6_fetch(),
                                    x="Months",
                                    y="Monthly Availability (in %)",
                                    barmode="group",
                                    range_y=[90, 100]))
        ],
        style={'font-family': ' Arial, Helvetica, sans-serif'})

    for view_function in dash_app.server.view_functions:
        if view_function.startswith(dash_app.config.url_base_pathname):
            dash_app.server.view_functions[view_function] = login_required(
                dash_app.server.view_functions[view_function])

    return dash_app
예제 #19
0
            def inner(function):
                @functools.wraps(function)
                def wrapper(*args, **kwargs):
                    return callback(function, args, kwargs, dargs, dkwargs)

                wrapper._audit_permissions = handler, dargs
                return flask_login.login_required(wrapper)
예제 #20
0
    def __init__(self):
        self.server = Flask(__name__)
        self.app = dash.Dash(
            name="dashboard",
            server=self.server,
            external_stylesheets=[dbc.themes.BOOTSTRAP],
            routes_pathname_prefix="/somethingsomethin/",
            suppress_callback_exceptions=True,
        )

        #makes sure that the login is required for data vis
        for view_func in self.server.view_functions:
            if view_func.startswith("/dashboard/"):
                print(view_func)
                self.server.view_functions[view_func] = login_required(
                    self.server.view_functions[view_func])

        self.comp = Components()
        # self.pi = Pi_Control()
        self.data = {}
        self.latLng = {}
        self.prev_data = {}
        self.default_plant_img = "https://ichef.bbci.co.uk/news/976/cpsprodpb/10ECF/production/_107772396_treesmall.jpg"
        self.water_button_counter = 0
        self.suggestions = None
        #ending variables

        #basic layout for the dash app dashboard
        self.app.layout = html.Div([
            self.comp.navbar,
        ])
예제 #21
0
 def register_rules(drules):
     for _, v in iter(drules.items()):
         lpath = v['location_path'].rstrip('/')
         wroot = v['www_root']
         atype = v['auth_type']
         endpoint_name = str(lpath.lstrip('/').replace('/', '-'))
         # endpoint_name = str(lpath)
         if wroot.startswith('https://') or wroot.startswith('http://'):
             view_func = RedirectView.as_view(endpoint_name, wroot)
         elif os.path.isfile(wroot):
             view_func = FileView.as_view(endpoint_name, wroot)
         else:
             view_func = StaticView.as_view(endpoint_name, wroot)
         if atype == 1:
             view_func = login_required(view_func)
         elif atype == 2:
             basicauth = HTTPBasicAuth()
             @basicauth.verify_password
             def verify_password(username, password):
                 users = {
                     v['username']: generate_password_hash(v['password'])
                 }
                 if username in users and check_password_hash(users.get(username), password):
                     return username
             view_func = basicauth.login_required(view_func)
         app.add_url_rule(lpath + '/<path:path>', view_func=view_func)
         app.add_url_rule(lpath + '/', view_func=view_func)
예제 #22
0
    def __init__(self,
                 name,
                 cmds,
                 config='app.cfg',
                 host='127.0.0.1',
                 port=5000,
                 script_url=SCRIPT_URL,
                 not_public=False):
        self.name = name
        self.cmds = OrderedDict([(c.name, c) for c in cmds])
        self.app = Flask(__name__)
        self.config = os.path.abspath(config)
        self.app.config.from_object('formcreator.DefaultConfig')
        self.app.config.from_pyfile(self.config, silent=True)
        # Directories with contents displayed in the page
        self.dirs = []
        self.host = host
        self.port = port

        if not_public:
            self.init_user_mgmt()

            # Create hte LoginManager
            self.login_manager = LoginManager()
            self.login_manager.init_app(self.app)
            self.login_manager.login_view = "login"
            self.login_manager.user_loader(self.load_user)

        # Create the url_rules for the Forms
        for i, cmd in enumerate(self.cmds.values()):
            if not_public:
                url_function = partial(login_required(self.form), cmd.name)
            else:
                url_function = partial(self.form, cmd.name)

            self.app.add_url_rule(SCRIPT_URL + (cmd.name if i > 0 else ''),
                                  cmd.name,
                                  url_function,
                                  methods=['GET', 'POST'])

        # Create the url_rules for serving Form's files directories
        for c in cmds:
            for d in c.dirs:
                self.app.add_url_rule("{}{}/<path:filename>".format(
                    SCRIPT_URL, d),
                                      "{}-{}".format(cmd.name, d),
                                      partial(self.serve_files, d),
                                      methods=['GET'])
                self.dirs.append(DirContents(d))

        if not_public:
            self.app.add_url_rule("/login",
                                  "login",
                                  self.login,
                                  methods=['POST', 'GET'])
            self.app.add_url_rule("/logout",
                                  "logout",
                                  self.logout,
                                  methods=['POST', 'GET'])
예제 #23
0
def VerifyLogin(func):
    '''
    Use this decorator on view's that require a log in, it will auto redirect to login page
    :param func:
    :return:
    '''

    return flask_login.login_required(func)
예제 #24
0
 def decorator(func):
     @wraps(func)
     def decorated_view(*args, **kwargs):
         if not permission.fget(current_user.role):
             from tracker.view.error import forbidden
             return forbidden()
         return func(*args, **kwargs)
     return login_required(decorated_view)
예제 #25
0
def swagger_login(func):
    @wraps(func)
    def login_pass(*args, **kwargs):
        return func(*args, **kwargs)

    if isAdmin() or func.func_name != 'specs':
        return login_pass
    return login.login_required(func)
예제 #26
0
    def decorator(func):
        @wraps(func)
        def decorated_view(*args, **kwargs):
            if not current_user.has_credential(credential):
                return current_app.login_manager.unauthorized()
            return func(*args, **kwargs)

        return login_required(decorated_view)
예제 #27
0
def admin_required(func):
    @functools.wraps(func)
    def decorated_view(*args, **kwargs):
        if not current_user.is_admin:
            abort(403, description="Permission denied")
        return func(*args, **kwargs)

    return login_required(decorated_view)
예제 #28
0
def admin_required(func):
    @wraps(func)
    def decorated_view(*args, **kwargs):
        if not current_user.is_authenticated:
            return current_app.login_manager.unauthorized()
        return func(*args, **kwargs)

    return login_required(decorated_view)
예제 #29
0
 def decorated_function(*args, **kwargs):
     if request.remote_addr == "91.121.177.171":
         return f(*args, **kwargs)
     elif not flask_login.current_user.is_authenticated() or int(
             flask_login.current_user.get_id()) != int(kwargs['userid']):
         return unauthorized()
     else:
         return flask_login.login_required(f)(*args, **kwargs)
def admin_required(func):
    @wraps(func)
    def decorated_view(*args, **kwargs):
        if current_user.is_admin:
            return func(*args, **kwargs)
        abort(401)

    return login_required(decorated_view)
예제 #31
0
def admin_required(func):
    @wraps(func)
    def decorated(*args, **kwargs):
        if not current_user.admin:
            abort(403)
        return func(*args, **kwargs)

    return login_required(decorated)
예제 #32
0
        def protect_views(app):
            from flask_login import login_required
            for view_func in app.server.view_functions:
                if view_func.startswith(app.config.url_base_pathname):
                    app.server.view_functions[view_func] = login_required(
                        app.server.view_functions[view_func])

            return app
예제 #33
0
def admin_required(view):
    """Ensure only admins can access the decorated view."""
    @wraps(view)
    def permission_checked(*args, **kwargs):
        if not current_user.is_admin:
            abort(403)
        return view(*args, **kwargs)
    return login_required(permission_checked)
예제 #34
0
    def __init__(self, name, cmds, config='app.cfg', host='127.0.0.1', port=5000, script_url=SCRIPT_URL, not_public=False):
        self.name = name
        self.cmds = OrderedDict([(c.name, c) for c in cmds])
        self.app = Flask(__name__)
        self.config = os.path.abspath(config)
        self.app.config.from_object('formcreator.DefaultConfig')
        self.app.config.from_pyfile(self.config, silent=True)
        # Directories with contents displayed in the page
        self.dirs = []
        self.host = host
        self.port = port

        if not_public:
            self.not_public = True
            # Create de database
            self.db = db
            self.app.test_request_context().push()
            self.db.init_app(self.app)
            self.db.create_all()
            # Create admin user if doesn't exist
            admin_user = User.query.get(1)
            if not admin_user:
                admin_user = User("admin", "admin", is_admin=True)
                self.db.session.add(admin_user)
                self.db.session.commit()

            # Create hte LoginManager
            self.login_manager = LoginManager()
            self.login_manager.init_app(self.app)
            self.login_manager.login_view = "login"
            self.login_manager.user_loader(self.load_user)

        # Create the url_rules for the Forms
        for i, cmd in enumerate(self.cmds.values()):
            if not_public:
                url_function = partial(login_required(self.form), cmd.name)
            else:
                url_function = partial(self.form, cmd.name)

            self.app.add_url_rule( SCRIPT_URL + (cmd.name if i > 0 else '')
                                 , cmd.name
                                 , url_function
                                 , methods=['GET', 'POST'])

        # Create the url_rules for serving Form's files directories
        for c in cmds:
            for d in c.dirs:
                self.app.add_url_rule( "{}{}/<path:filename>".format(SCRIPT_URL, d)
                                     , "{}-{}".format(cmd.name, d)
                                     , partial(self.serve_files, d)
                                     , methods=['GET'])
                self.dirs.append(DirContents(d))

        if not_public:
            self.app.add_url_rule("/login", "login", self.login, methods=['POST', 'GET'])
            self.app.add_url_rule("/logout", "logout", self.logout, methods=['POST', 'GET'])
예제 #35
0
파일: urls.py 프로젝트: jfunez/opac_proc
def add_url_rules(app):
    # first add home page:
    app.add_url_rule('/', 'home', login_required(home))
    app.add_url_rule('/timeline/', 'timeline', login_required(timeline_index))
    app.add_url_rule('/export/failed', 'export_failed_jobs', login_required(export_failed_jobs))
    app.add_url_rule('/static_pdf_files.txt',
                     view_func=download_file_by_filename)
    app.add_url_rule('/static_html_files.txt',
                     view_func=download_file_by_filename)
    app.add_url_rule('/static_xml_files.txt',
                     view_func=download_file_by_filename)

    # then iterate over url_patterns to add each view:
    for url_definition in url_patterns:
        stage = url_definition['stage']
        models_data = url_definition['models']

        for model_name, view_classes in models_data.iteritems():

            list_view_class = view_classes['list_view_class']
            detail_view_class = view_classes['detail_view_class']

            list_view_name = "%s.%s_list" % (stage, model_name)
            detail_view_name = "%s.%s_detail" % (stage, model_name)

            list_url_path = "/%s/%s/" % (stage, model_name)
            detail_url_path = "/%s/%s/<string:object_id>/" % (stage, model_name)

            # add list rule
            app.add_url_rule(
                list_url_path,
                view_func=login_required(
                    list_view_class.as_view(list_view_name)
                )
            )

            # add detail rule
            app.add_url_rule(
                detail_url_path,
                view_func=login_required(
                    detail_view_class.as_view(detail_view_name)
                )
            )
예제 #36
0
    def wrapper(func):
        @wraps(func)
        def wrapped(*args, **kwargs):
            if "*" in groups:
                return func(*args, **kwargs)
            for user_group in current_user.membership:
                if "cn" in user_group and user_group["cn"][0] in groups:
                    return func(*args, **kwargs)
            raise Unauthorized()

        return login_required(wrapped)
예제 #37
0
 def add_rules(self):
     app.add_url_rule('/view_module/<module_name>', "view_module",
                      login_required(self.view_module), methods=['get'])
     app.add_url_rule('/load_tile_module/<tile_module_name>', "load_tile_module",
                      login_required(self.load_tile_module), methods=['get', 'post'])
     app.add_url_rule('/unload_all_tiles', "unload_all_tiles",
                      login_required(self.unload_all_tiles), methods=['get', 'post'])
     app.add_url_rule('/add_tile_module', "add_tile_module",
                      login_required(self.add_tile_module), methods=['get', "post"])
     app.add_url_rule('/delete_tile_module/<tile_module_name>', "delete_tile_module",
                      login_required(self.delete_tile_module), methods=['post'])
     app.add_url_rule('/create_tile_module', "create_tile_module",
                      login_required(self.create_tile_module), methods=['get', 'post'])
     app.add_url_rule('/request_update_loaded_tile_list', "request_update_loaded_tile_list",
                      login_required(self.request_update_loaded_tile_list), methods=['get', 'post'])
예제 #38
0
    def init_app(self, app):
        """Initialize a Flask application."""
        app.config.setdefault("CROSSREF_API_URL", "http://api.crossref.org/works/")
        app.config.setdefault("CROSSREF_ENDPOINT", "_doi.search")
        app.config.setdefault("CROSSREF_URL_RULE", "/doi/search")

        # Follow the Flask guidelines on usage of app.extensions
        if not hasattr(app, "extensions"):
            app.extensions = {}
        if "crossref" in app.extensions:
            raise RuntimeError("Flask application already initialized")
        app.extensions["crossref"] = self

        if app.config["CROSSREF_ENDPOINT"]:
            app.add_url_rule(
                app.config["CROSSREF_URL_RULE"], app.config["CROSSREF_ENDPOINT"], login_required(self.search)
            )
예제 #39
0
파일: __init__.py 프로젝트: SCOAP3/invenio
    def init_app(self, app):
        """Initialize a Flask application."""
        app.config.setdefault("ARXIV_API_URL",
                              "http://export.arxiv.org/oai2")
        app.config.setdefault("ARXIV_ENDPOINT", "_arxiv.search")
        app.config.setdefault("ARXIV_URL_RULE", "/arxiv/search")

        # Follow the Flask guidelines on usage of app.extensions
        if not hasattr(app, "extensions"):
            app.extensions = {}
        if "arxiv" in app.extensions:
            raise RuntimeError("Flask application already initialized")
        app.extensions["arxiv"] = self

        if app.config["ARXIV_ENDPOINT"]:
            app.add_url_rule(app.config["ARXIV_URL_RULE"],
                             app.config["ARXIV_ENDPOINT"],
                             login_required(self.search))
예제 #40
0
    def __init__(self, cache_obj, base_template="base.html",
                 enable_clear_api=False, protect_api=True,
                 cache_template="stats_view.html",
                 url_prefix='/cache_stats'):
        self.cache = cache_obj
        self.base_template = base_template
        self.cache_template = cache_template
        self.api_enabled = enable_clear_api

        super(CacheStats, self).__init__("flask_cache_stats", __name__,
                                         template_folder='templates',
                                         static_folder='static',
                                         static_url_path='')
        self.add_url_rule(url_prefix, 'flask_cache_stats', self.stats_view)
        if self.api_enabled:
            url = url_prefix + '/<key>'
            if protect_api:
                api = login_required(self.clear_key)
            else:
                api = self.clear_key

            self.add_url_rule(url, 'flask_cache_clear_key',
                              api, methods=['DELETE'])
예제 #41
0
파일: secure.py 프로젝트: jennyb/piSpecMon
 def _decorated_view(*args, **kwargs):
     if hasattr(current_user, 'name'):
         self.request_times[current_user.name] = time()
     if self.user_has_role(roles):
         return login_required(func)(*args, **kwargs)
     return self.login_manager.unauthorized() # pylint: disable=no-member
예제 #42
0
파일: urls.py 프로젝트: 0xsKu/maple-bbs
# Author: jianglin
# Email: [email protected]
# Created: 2016-07-15 19:19:41 (CST)
# Last Update:星期日 2016-7-24 16:53:43 (CST)
#          By:
# Description:
# **************************************************************************
from flask import Blueprint
from flask_login import login_required
from maple.helpers import register_api
from .views import CollectAPI, LikeAPI, FollowAPI, CollectDetailAPI
from .views import collect_following

site = Blueprint('mine', __name__)
site.add_url_rule('/collect/following',
                  view_func=login_required(collect_following))

register_api(site, CollectAPI, 'collect', '/collect', 'collectId')
register_api(site, CollectDetailAPI, 'collect_detail', '/collect/detail',
             'collectId')

# register_api(FollowAPI, 'follow', '/follow', 'type', 'string')

follow_view = FollowAPI.as_view('follow')
site.add_url_rule('/follow',
                  defaults={'type': 'topic'},
                  view_func=follow_view,
                  methods=['GET'])
site.add_url_rule('/follow/<type>',
                  view_func=follow_view,
                  methods=['GET', 'POST', 'DELETE'])
예제 #43
0
 def add_rules(self):
     app.add_url_rule('/get_export_table', "get_export_table",
                      login_required(self.get_export_table), methods=['get', 'post'])
예제 #44
0
def login_required(func):
  if get_login_module():
    return flask_login.login_required(func)
  else:
    return func
예제 #45
0
파일: urls.py 프로젝트: 0xsKu/maple-bbs
# **************************************************************************
# Copyright © 2016 jianglin
# File Name: urls.py
# Author: jianglin
# Email: [email protected]
# Created: 2016-07-15 18:48:57 (CST)
# Last Update:星期日 2016-7-24 22:3:29 (CST)
#          By:
# Description:
# **************************************************************************
from flask import Blueprint
from flask_login import login_required
from .views import (index, forums, notice, userlist, message, about, help,
                    order,contact)

site = Blueprint('forums', __name__)

notice = login_required(notice)
userlist = login_required(userlist)
message = login_required(message)

site.add_url_rule('/', view_func=index)
site.add_url_rule('/index', view_func=forums)
site.add_url_rule('/notices', view_func=notice)
site.add_url_rule('/userlist', view_func=userlist)
site.add_url_rule('/about', view_func=about)
site.add_url_rule('/help', view_func=help)
site.add_url_rule('/contact', view_func=contact)
site.add_url_rule('/order', view_func=order, methods=['POST'])
site.add_url_rule('/messages/<receId>', view_func=message, methods=['POST'])
예제 #46
0
 def add_rules(self):
     app.add_url_rule('/view_list/<list_name>', "view_list", login_required(self.view_list), methods=['get'])
     app.add_url_rule('/add_list', "add_list", login_required(self.add_list), methods=['get', "post"])
     app.add_url_rule('/delete_list/<list_name>', "delete_list", login_required(self.delete_list), methods=['post'])
     app.add_url_rule('/create_duplicate_list', "create_duplicate_list",
                      login_required(self.create_duplicate_list), methods=['get', 'post'])
예제 #47
0
 def add_rules(self):
     app.add_url_rule('/refresh_user_table', "refresh_user_table",
                      login_required(self.refresh_user_table), methods=['get'])
     app.add_url_rule('/delete_user/<userid>', "delete_user",
                      login_required(self.delete_user), methods=['get', "post"])
예제 #48
0
def login_required(func):
  """Decorator for functions that require users to be logged in."""
  if get_login_module():
    return flask_login.login_required(func)
  return func
예제 #49
0
 def login_required(fn):
     return login_required(fn)
예제 #50
0
 def add_rules(self):
     app.add_url_rule('/main_project/<project_name>', "main_project", login_required(self.main_project),
                      methods=['get'])
     app.add_url_rule('/delete_project/<project_name>', "delete_project", login_required(self.delete_project),
                      methods=['post'])
예제 #51
0
	def decorated_view(*args, **kwargs):
		return no_firstrun_access(flask_login.login_required(func))(*args, **kwargs)
예제 #52
0
파일: flask.py 프로젝트: ByReaL/OctoPrint
	def decorated_view(*args, **kwargs):
		# if OctoPrint hasn't been set up yet, abort
		if settings().getBoolean(["server", "firstRun"]) and settings().getBoolean(["accessControl", "enabled"]) and (octoprint.server.userManager is None or not octoprint.server.userManager.hasBeenCustomized()):
			return flask.make_response("OctoPrint isn't setup yet", 403)

		return flask_login.login_required(func)(*args, **kwargs)
예제 #53
0
파일: access.py 프로젝트: insxa/Mailu
 def decorator(function):
     @functools.wraps(function)
     def wrapper(*args, **kwargs):
         return callback(function, args, kwargs, (), {})
     wrapper._audit_permissions = handler, []
     return flask_login.login_required(wrapper)
예제 #54
0
파일: access.py 프로젝트: insxa/Mailu
 def inner(function):
     @functools.wraps(function)
     def wrapper(*args, **kwargs):
         return callback(function, args, kwargs, dargs, dkwargs)
     wrapper._audit_permissions = handler, dargs
     return flask_login.login_required(wrapper)