Login

Tag "anonymous"

Snippet List

Support for permissions for anonymous users in django ModelBackend

Model backend that enables permissions for AnonymusUsers. I wanted it to be as simple as possible so anonymous users just forward their permission checks to some fixed user model. This instance can be edited via django admin, assigned to groups, etc. To control which user will represent anonymous user you use ANONYMOUS_USER_NAME setting in settings file. To provide some sensible level of security i enforce following for user that represents anonymous user: * This user must have password equal to UNUSABLE_PASSWORD * This user may not log in * You cant cange password for this user via admin. You need to enable this backend by setting AUTHENTICATION_BACKENDS. Please note that you should not place this backend alongside django ModelBackend. This backend inherits from it.

  • user
  • auth
  • permissions
  • anonymous
Read More
Author: jb
  • 1
  • 1

New view decorator to only cache pages for anonymous users

This is an addition to Django's cache_page decorator. I wanted to cache pages for anonymous users but not cache the same page for logged in users. There's middleware to do this at a site-wide level, and it also gives you the ability to partition anonymous users, but then you have to tell Django which pages not to cache with @never_cache.

  • cache
  • view
  • decorator
  • anonymous
Read More

Use both NTLM and Anonymous authentication with IIS

Point '^accounts/login/$' or whatever your custom login path is to the 'negotiate_ntlm' view. This allows you to keep anonymous authentication enabled on IIS and easily lock down just the parts of the site you need to (e.g. [admin](http://djangosnippets.org/snippets/2127/)).

  • admin
  • authentication
  • anonymous
  • iis
  • ntlm
Read More

create and authenticate an anonymous user

If you want anonymous visitors to your site, or parts of your site to be authenticated as real users so that you can treat them as such in your views and models, use this snippet. Add the above AuthenticationBackendAnonymous middleware into AUTHENTICATION_BACKENDS in your settings.py and use the snippet anonymous_or_real(request) in your views, which returns a user. Comment out the bit where it creates a profile if you are not using profiles.

  • authentication
  • anonymous
Read More

5 snippets posted so far.