Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong redirection after successful authentication to the admin page #222

Open
Sergiy-Begun opened this issue Jul 10, 2023 · 3 comments
Open

Comments

@Sergiy-Begun
Copy link

Sergiy-Begun commented Jul 10, 2023

After successful authentication to the admin page, redirection to the always the same non-existing address "/admin/sprite-8cfe9c6c/" sometimes occurs instead of registered URL-path "/admin/" (wagtail admin).
/admin/sprite-8cfe9c6c/ is the empty (blank) page without Wagtail's admin page menus.
The Wagtail version is 5.0.2.
The Django version is 4.2.3.
Changing the Django version to 4.0.10 does not influence the issue.

@Sergiy-Begun Sergiy-Begun changed the title Redirection after successful authentication to the admin page Wrong redirection after successful authentication to the admin page Jul 10, 2023
@Sergiy-Begun Sergiy-Begun closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2023
@Sergiy-Begun Sergiy-Begun changed the title Wrong redirection after successful authentication to the admin page 1 Jul 14, 2023
@Sergiy-Begun Sergiy-Begun reopened this Jul 23, 2023
@Sergiy-Begun Sergiy-Begun changed the title 1 Wrong redirection after successful authentication to the admin page Jul 23, 2023
@dev-ptr
Copy link

dev-ptr commented Jul 27, 2023

Experiencing the same issue, it appears the form is appearing twice, if you scroll down to the second form it appears to show "successfully logged in" and the otp form redirects properly.

@jardev
Copy link

jardev commented Sep 20, 2023

There is the following code in Wagtail's skeleton template:

    <body id="wagtail" class="{% block bodyclass %}{% endblock %} {% if sidebar_collapsed %}sidebar-collapsed{% endif %} {% if messages %}has-messages{% endif %}">
        <div data-sprite></div>

        <script src="{% versioned_static 'wagtailadmin/js/icons.js' %}" data-icon-url="{% url 'wagtailadmin_sprite' %}"></script>

and the script wagtailadmin/js/icons.js loads sprites from wagtailadmin_sprite url, which usually looks like /admin/sprite-8cfe9c6c, and of course when it's accessed, it gets the 2FA auth page and inserts it into this

.

Looks like it's enough to add that url to VerifyUserMiddleware._allowed_url_names in order to fix the issue.

As a temporary solution I subclassed the original VerifyUserMiddleware adding "wagtailadmin_sprite" to _allowed_url_names:

from wagtail_2fa.middleware import VerifyUserMiddleware as VerifyUserMiddlewareBase

class VerifyUserMiddleware(VerifyUserMiddlewareBase):
    _allowed_url_names = [
        "wagtail_2fa_auth",
        "wagtailadmin_login",
        "wagtailadmin_logout",
        "wagtailadmin_javascript_catalog",
        "wagtailadmin_sprite",
    ]

and then using the customized middleware in my project.

@pruszel
Copy link

pruszel commented Nov 1, 2023

looks like this was fixed by #219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants