Allow customising the admin login URL
- Dominant language
- No language data
- Stars
- 188
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
### Code of Conduct
- [x] 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_URL` or similar
- extracting it to a property on `AdminSite` to make overriding it in a subclass easier
- etc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.