summaryrefslogtreecommitdiff
path: root/django/contrib/auth/decorators.py
AgeCommit message (Collapse)Author
2026-01-31Refs #34118 -- Removed asgiref coroutine detection shims.Jacob Walls
As Python 3.12 is now the floor, we can drop the shims and use the `inspect` module.
2024-10-17Refs #35844 -- Used asgiref.sync.iscoroutinefunction() instead of deprecated ↵Mariusz Felisiak
asyncio.iscoroutinefunction(). Fixes DeprecationWarning: 'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead.
2024-10-07Fixed #35303 -- Implemented async auth backends and utils.Jon Janzen
2024-05-29Fixed 35467 -- Replaced urlparse with urlsplit where appropriate.Jake Howard
This work should not generate any change of functionality, and `urlsplit` is approximately 6x faster. Most use cases of `urlparse` didn't touch the path, so they can be converted to `urlsplit` without any issue. Most of those which do use `.path`, simply parse the URL, mutate the querystring, then put them back together, which is also fine (so long as urlunsplit is used).
2024-05-22Fixed #31405 -- Added LoginRequiredMiddleware.Hisham Mahmood
Co-authored-by: Adam Johnson <me@adamj.eu> Co-authored-by: Mehmet İnce <mehmet@mehmetince.net> Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2024-03-07Fixed #35030 -- Made django.contrib.auth decorators to work with async ↵Dingning
functions.
2022-05-25Renamed wrapped functions to wrapper.Aymeric Augustin
All these functions are wrapping another function. They're the wrapper, while the function they're wrapping is the wrapped.
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2017-12-28Removed unnecessary trailing commas and spaces in various code.Mariusz Felisiak
2017-01-21Refs #23919 -- Removed django.utils.decorators.available_attrs() usage.Tim Graham
It's only needed to workaround a bug on Python 2.
2017-01-18Refs #23919 -- Removed most of remaining six usageClaude Paroz
Thanks Tim Graham for the review.
2017-01-18Refs #23919 -- Removed six.<various>_types usageClaude Paroz
Thanks Tim Graham and Simon Charette for the reviews.
2016-04-09Fixed #25847 -- Made User.is_(anonymous|authenticated) properties.Jeremy Lainé
2015-06-08Fixed #24929 -- Allowed permission_required decorator to take any iterableRaphael Michel
2015-02-06Sorted imports with isort; refs #23860.Tim Graham
2015-01-10Fixed #24097 -- Prevented AttributeError in redirect_to_loginClaude Paroz
Thanks Peter Schmidt for the report and the initial patch. Thanks to ​Oktay Sancak for writing the original failing test and Alvin Savoy for supporting contributing back to the community.
2014-03-03Fixed many typos in comments and docstrings.Rodolfo Carvalho
Thanks Piotr Kasprzyk for help with the patch.
2013-11-28Fixed E125 pep8 warningsChristopher Medrela
2013-09-05Took advantage of django.utils.six.moves.urllib.*.Aymeric Augustin
2013-08-10Fixed #20828 -- Allowed @permission_required to take a list of permissionsersran9
Thanks Giggaflop for the suggestion.
2012-09-09Fix Python 3 test failure introduced in a78dd109.Carl Meyer
2012-09-08Fixed #15552 -- LOGIN_URL and LOGIN_REDIRECT_URL can take URLpattern names.Carl Meyer
Thanks UloPe and Eric Florenzano for the patch, and Malcolm Tredinnick for review.
2012-08-18[py3] Avoided passing a lazy string to urlparse.Aymeric Augustin
This causes an exception under Python 3. Fixed #18776.
2012-07-22[py3] Updated urllib/urllib2/urlparse imports.Aymeric Augustin
Lots of functions were moved. Use explicit imports in all cases to keey it easy to identify where the functions come from.
2011-08-12Fixed #4617 -- Added `raise_exception` option to `permission_required` ↵Jannis Leidel
decorator to be able to raise a PermissionDenied exception instead of redirecting to the login page. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16607 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-28Removed a bunch of Python 2.4 workarounds now that we don't support it. Refs ↵Adrian Holovaty
#15702 -- thanks to jonash for the patch. Splitting this over muliple commits to make it more manageable. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-27Fixes #11025 -- ability to specify LOGIN_URL as full qualified absolute URL.Chris Beaven
auth.views.login now allows for login redirections for different schemes with the same host (or no host even, e.g. 'https:///login/') auth.decorators.login_required can now use lazy urls (refs #5925) git-svn-id: http://code.djangoproject.com/svn/django/trunk@14733 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-09-10Added login_url argument to login_required decorator. Thanks mhlakhani and ↵Jannis Leidel
ericflo for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13723 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-05-04Fixed #12164 -- Removed the Python 2.3 compatibility imports and ↵Russell Keith-Magee
workarounds. Thanks to timo and claudep for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-04-09Fixed #13304 -- Updated auth decorators so they can be used with callable ↵Russell Keith-Magee
classes. Thanks to Horst Gutmann for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12938 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-02-09Fixed #12804 - regression with decorating admin views.Luke Plant
This is a BACKWARDS INCOMPATIBLE change, because it removes the flawed 'auto_adapt_to_methods' decorator, and replaces it with 'method_decorator' which must be applied manually when necessary, as described in the 1.2 release notes. For users of 1.1 and 1.0, this affects the decorators: * login_required * permission_required * user_passes_test For those following trunk, this also affects: * csrf_protect * anything created with decorator_from_middleware If a decorator does not depend on the signature of the function it is supposed to decorate (for example if it only does post-processing of the result), it will not be affected. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12399 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-09-21Rewrote user_passes_test to use auto_adapt_to_methods, removing the need for ↵Luke Plant
_CheckLogin git-svn-id: http://code.djangoproject.com/svn/django/trunk@11587 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-04-01Fixed #9474: user_passes_test may now be applied multiple times.Jacob Kaplan-Moss
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10328 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-22Fixed #7847 -- Removed a whole bunch of unused imports from throughout the ↵Adrian Holovaty
codebase. Thanks, julien git-svn-id: http://code.djangoproject.com/svn/django/trunk@8046 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-02-25Fixed #5701 -- Fixed decorators to take the name, attributes, and docstring ↵Gary Wilson Jr
of the function they decorate by adding a modified version of the `functools.wraps` function from Python 2.5. `wraps` has been altered to work with Django's `curry` function and with Python 2.3, which doesn't allow assignment of a function's `__name__` attribute. This fixes severaly annoyances, such as the online documentation for template filters served by the admin app. This change is backwards incompatible if, for some reason, you were relying on the name of a Django decorator instead of the function it decorates. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7153 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-09Fixed bug in /admin/doc/views/ caused by [6658]Luke Plant
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6659 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-07Fixed #4376 -- login_required now works with bound methods. Thanks, Steven ↵Luke Plant
Bethard. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6658 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-09-14Fixed #5308 -- Redirect from pages that need login and have Unicode URL no ↵Adrian Holovaty
longer causes error. Thanks, webjunkie git-svn-id: http://code.djangoproject.com/svn/django/trunk@6226 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-09-14Fixed #5394 -- REDIRECT_FIELD_NAME is now configurable. Thanks, Petr ↵Adrian Holovaty
Marhoun, DavidReynolds and effbot git-svn-id: http://code.djangoproject.com/svn/django/trunk@6206 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-04-25Fixed #3185 -- Made values for login, logout and post-login redirect URLsMalcolm Tredinnick
configurable. This is a combined patch from Vasily Sulatskov, Marc Fargas and Collin Grady. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5072 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-09-25Fixed typos and improved documentation for permission_required decorator ↵Adrian Holovaty
addition from [3779] git-svn-id: http://code.djangoproject.com/svn/django/trunk@3835 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-09-22Fixed #2629 -- Added a permission_required decorator toMalcolm Tredinnick
django.contrib.auth.decorator. Thanks, dummy@habmalnefrage.de. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3779 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-07-28Removed bug from [3461] -- __name__ is not assignableAdrian Holovaty
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3478 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-07-27Fixed #2388 -- login_required decorator now preserves docstring and name of ↵Adrian Holovaty
decorated function. Thanks, derekgr@gmail.com git-svn-id: http://code.djangoproject.com/svn/django/trunk@3461 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-07-19Fixed #2332 -- Introduced is_authenticated() method on User and ↵Malcolm Tredinnick
AnonymousUser classes. Recommended its use over is_anonymous in the docs. Changed internal Django use to match this recommendation. Thanks to SmileyChris and Gary Wilson for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3360 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-05-22Fixed #849 -- Improved login_required view decorator to save query-string ↵Adrian Holovaty
parameters. Also added documentation on the django.contrib.auth.views.login view to docs/authentication.txt git-svn-id: http://code.djangoproject.com/svn/django/trunk@2954 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-05-02MERGED MAGIC-REMOVAL BRANCH TO TRUNK. This change is highly ↵Adrian Holovaty
backwards-incompatible. Please read http://code.djangoproject.com/wiki/RemovingTheMagic for upgrade instructions. git-svn-id: http://code.djangoproject.com/svn/django/trunk@2809 bcc190cf-cafb-0310-a4f2-bffc1f526a37