-
Notifications
You must be signed in to change notification settings - Fork 6
Allow customising the admin login URL #133
Description
Code of Conduct
- I agree to follow Django's Code of Conduct
Feature Description
Provide a hook to change/customise the admin login URL, to allow users to point it to custom login views such as an SSO redirect or similar.
Problem
We have many Django projects that are fronted by SSO. The LOGIN_URL setting is pointed to the social auth login view that issues the redirect to the SSO provider to initiate login. However, if the user first loads a Django Admin URL, the Django Admin login page is presented instead, ignoring the value of LOGIN_URL.
This is because it is hardcoded in get_urls of the AdminSite class: https://github.com/django/django/blob/6.0/django/contrib/admin/sites.py#L270
This cannot be overridden without either duplicating most of the get_urls function within your own AdminSite subclass, or defining a URL pattern that matches the path for admin:login but sits higher in the URL pattern hierarchy so hijacks requests for it. Both options seem like a hack.
Request or proposal
request
Additional Details
There is a good chance I am missing something obvious with how to override it in the current setup, or why it would be a bad idea to allow customisation anyway, so please do let me know if so!
Implementation Suggestions
Any mechanism for overriding the hardcoded admin:login URL could be adopted:
- a new setting for
ADMIN_LOGIN_URLor similar - extracting it to a property on
AdminSiteto make overriding it in a subclass easier - etc
Metadata
Metadata
Assignees
Labels
Type
Projects
Status