hirokiky / django-basicauth Goto Github PK
View Code? Open in Web Editor NEWBasic auth utilities for Django.
License: MIT License
Basic auth utilities for Django.
License: MIT License
Hi, can you tag the 0.5.1 release?
Thanks
The decorator function to import is @basic_auth_required, not @basic_auth_decorator.
Hi,
could you please provide an example how to use django-basicauth with class-based-views?
I just want to have one CBV decorated. I would like to avoid a middleware.
Thank you
Hi,
I'm interested in getting a middleware version of this feature; are you interesting in my contributing it?
If so, do you have any speicifc expectations on incoming pull requests?
Thanks!
from .basicauthutils import validate_request
from .response import HttpResponseUnauthorized
from django.utils.deprecation import MiddlewareMixin
class BasicAuthMiddleware(MiddlewareMixin):
def process_request(self, request):
if not validate_request(request):
return HttpResponseUnauthorized()
return None
See #7
Hi.
Thanks for this package. I am using it to apply a basic auth restriction to staging deploys for a couple of my websites.
I host my sites on AWS behind an Elastic Load Balancer (ELB). When you set up an ELB, you give it a 'health check' URL. The Load Balancer periodically requests this URL and checks the responses status is 200 OK
to ensure the server is 'healthy'. If it gets anything other than a 200 OK
, it marks the server as unhealthy. The load balancer doesn't have the option to pass auth credentials.
What this means is I want to set up my staging deploys with basic auth applied to every endpoint except for one which isn't protected so that the load balancer can ping that endpoint and get a 200 OK
rather than a 401 Unauthorized
. Every other route should be behind basic auth. For obvious reasons, it is cumbersome to decorate every view other than one with @basic_auth_required
so they way I've done this is by subclassing BasicAuthMiddleware
so that I can turn on basic auth for everything but then whitelist one endpoint using a regex. I've taken inspiration from the old django-moat package which is no longer maintained but did have this feature.
example: https://github.com/DemocracyClub/EveryElection/blob/master/every_election/apps/core/middleware.py
2 questions:
Cheers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.