From a security standpoint, this seems like a really bad idea.
That said, it can still be done. I'm hoping you're planning on using this only on something that would be internal or a company intranet of some sort. For a live, on-the-web, legit website, this is probably just asking for trouble.
You can handle incoming requests by creating a middleware component to do so.
(untested, but the general idea)
import base64
class UUIDQueryStringMiddleware(object):
def process_request(request):
if request.method == 'GET':
if not request.user.is_authenticated():
uuid = request.REQUEST.get('u', None)
if uuid:
username = base64.b64decode(uuid)
try:
user = User.objects.get(username=username)
request.user = user
except:
pass
# Pass the original request back to Django
return request
You would then need to setup this middleware to run before the auth and sessions middleware runs...
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'yourapp.middleware.UUIDQueryStringMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
See this question for more details on encoding/decoding: encrypt & decrypt strings in python
I REALLY hope you're not going to use this on a live site.