How to override wagtail authentication?

When I try to access the back-office in the wagtail /cms/

, wagtail, I redirected to the login page /cms/login/

.

However, I would like to use my own custom username, which is the default for the rest of the site, and sits at /auth/

.

Mine is LOGIN_URL

already set to /auth/

in django settings.

EDIT: It has been suggested that this is a general question of how you override url patterns with name expansion , but it is not. URLs are not renamed and I was looking for wagtail functionality that addressed this specific issue. Fortunately, this functionality exists.

+3


source to share


2 answers


Configuring Wagtail WAGTAIL_FRONTEND_LOGIN_URL

allows you to customize how users log into the Wagtail administrator.

From http://docs.wagtail.io/en/v1.10.1/advanced_topics/privacy.html#setting-up-a-login-page :



If the Django repository login view is not appropriate - for example, you want to use an external authentication system or integrate Wagtail into an existing Django site that already has a working login window - you can specify the login URL via the parameter WAGTAIL_FRONTEND_LOGIN_URL

+2


source


The WAGTAIL_FRONTEND_LOGIN_URL suggested above is specifically for end users only and there is no equivalent setting for admin users. You can use redirect_to_login

like this:



from django.contrib.auth.views import redirect_to_login
from django.urls import reverse

from wagtail.admin import urls as wagtailadmin_urls


def redirect_to_my_auth(request):
    return redirect_to_login(reverse('wagtailadmin_home'), login_url='myauth:login')



urlpatterns = [
    url(r'^cms/login', redirect_to_my_auth, name='wagtailadmin_login'),
    url(r'^cms/', include(wagtailadmin_urls)),
]

      

+1


source







All Articles