django-basic-authentication-decorator's People
Forkers
vladimir-mencl-eresearch mikebryant dystudio shubhamdipt leonardoce mludv 2ndquadrant-it axthebdjango-basic-authentication-decorator's Issues
Missing author data in package
The package currently omits the author field and thus does not allow to display the correct author when further using it without additional work.
TypeError: 'bool' object is not callable with Django 2.0.2 and Python 3.6
Using Django 2.0.2 and Python3.6.4 the following error occurs when a request with the decorator is called.
Traceback (most recent call last):
File "/opt/exaboard/eXaboard/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/opt/exaboard/eXaboard/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/opt/exaboard/eXaboard/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/exaboard/eXaboard/lib/python3.6/site-packages/django_basic_auth.py", line 81, in wrapper
realm, *args, **kwargs)
File "/opt/exaboard/eXaboard/lib/python3.6/site-packages/django_basic_auth.py", line 15, in view_or_basicauth
if test_func(request.user):
File "/opt/exaboard/eXaboard/lib/python3.6/site-packages/django_basic_auth.py", line 80, in
lambda u: u.is_authenticated(),
TypeError: 'bool' object is not callable
Decorator for Class Based Views
Add a decorator (or hide it in the current) to decorate class based views.
For Django 1.9 look at https://docs.djangoproject.com/en/1.9/topics/auth/default/#django.contrib.auth.mixins.AccessMixin and provide an AccessMixin.
Provide option to redirect to log in page if no auth present
Without the decorator, if, say @staff_member_required
were used instead, if a user isn't logged in they'd be redirected to the log in page.
I'd like to be able to get that behaviour here when the auth header isn't present.
TypeError when on a view with keyword arguments
On a URL with a placeholder, meaning its view gets keyword arguments named after the URL placeholders, such as
url(r'^admin/video/(?P<id>[0-9]+)/download$', admin.video_download, name='admin.video.download'),
I get
TypeError: view_decorator() got an unexpected keyword argument 'id'
Keyword argument before variable positional arguments list in the definition of view_or_basicauth function
The function view_or_basicauth()
has a bug. realm
cannot be declared as a keyword before the variable *args
. I believe the simple solution is to drop the assignment, otherwise you need to re-write to two callers ie: logged_in_or_basicauth
and has_perm_or_basicauth
. Removing the assignment seems like a safe action as both of the callers provide a default value.
Suggested signature:
def view_or_basicauth(view, request, test_func, realm, *args, **kwargs):
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.