这是indexloc提供的服务,不要输入任何密码
Skip to content

changing mfa_supported_methods breaks the application #6624

@roussidis

Description

@roussidis

In pgadmin v7.5 when running in server mode and have the option MFA_SUPPORTED_METHODS = ["authenticator"] ( Default is MFA_SUPPORTED_METHODS = ["email", "authenticator"]) the site breaks when the 2FA is enabled and can't login.

Dump log

2023-07-27 12:53:14,574: ERROR  pgadmin:  'mfa.send_email_code'
Traceback (most recent call last):
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/flask_login/utils.py", line 290, in decorated_view
    return current_app.ensure_sync(func)(*args, **kwargs)
  File "/usr/pgadmin4/web/pgadmin/authenticate/mfa/views.py", line 137, in validate_view
    return Response(render_template(
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/flask/templating.py", line 147, in render_template
    return _render(app, template, context)
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/flask/templating.py", line 130, in _render
    rv = template.render(context)
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/usr/pgadmin4/web/pgadmin/authenticate/mfa/templates/mfa/validate.html", line 2, in top-level template code
    {% set page_props = {
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/flask/app.py", line 2020, in url_for
    self.inject_url_defaults(endpoint, values)
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/flask/app.py", line 2257, in inject_url_defaults
    func(endpoint, values)
  File "/usr/pgadmin4/web/pgadmin/__init__.py", line 883, in add_internal_version
    urls = [url for url in app.url_map.iter_rules(endpoint)]
  File "/usr/pgadmin4/venv/lib/python3.10/site-packages/werkzeug/routing/map.py", line 164, in iter_rules
    return iter(self._rules_by_endpoint[endpoint])
KeyError: 'mfa.send_email_code'

When the option MFA_SUPPORTED_METHODS is reverted to its default one (["mail", "authenticator"]) then everything works as expected

To Reproduce

Steps to reproduce the behavior:

  1. Create a config_local.py or a config_system.py file with the option MFA_SUPPORTED_METHODS = ["authenticator"] and 2FA enabled
  2. Start the server
  3. Access pgadmin web interface and login.

Expected behavior

Expected behavior would be to be redirected to the Authenticator dialog box which will ask for the OTP

Desktop (please complete the following information):

  • OS: Debian 11 and Ubuntu 22 (has been reproduced in both systems)
  • Version: 7.5
  • Mode: Server
  • Browser tested on chrome but will break on any
  • Package type: deb

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions