コード例 #1
0
ファイル: bottle_app.py プロジェクト: flypunk/sds
def br():
    a_token = request.headers.get('Authorization')
    try: credentials = parse_auth(a_token)
    except:
        raise HTTPResponse('Please provide a Basic Authentication header\n', 403)
    if not utils.is_authenticated(*credentials): raise HTTPResponse(
        'Unauthenticated\n', 403)
    u_and_c = credentials[0].split('__')
    user = u_and_c[0]
    if len(u_and_c) >1:
        company = u_and_c[1]
    else:
        company = user
    request.creds = utils.LocalEnv()
    request.creds.user = user
    request.creds.company = company
    request.creds.password = credentials[1]
コード例 #2
0
def br():
    a_token = request.headers.get('Authorization')
    try:
        credentials = parse_auth(a_token)
    except:
        raise HTTPResponse('Please provide a Basic Authentication header\n',
                           403)
    if not utils.is_authenticated(*credentials):
        raise HTTPResponse('Unauthenticated\n', 403)
    u_and_c = credentials[0].split('__')
    user = u_and_c[0]
    if len(u_and_c) > 1:
        company = u_and_c[1]
    else:
        company = user
    request.creds = utils.LocalEnv()
    request.creds.user = user
    request.creds.company = company
    request.creds.password = credentials[1]
コード例 #3
0
ファイル: decorators.py プロジェクト: peterbe/djangopeoplenet
 def check_auth(request, *args, **kwargs):
     if request.session.has_key("access_token"):
         access_token = request.session.get("access_token")
         try:
             request.user = TwitterUser.objects.get(token=access_token)
         except TwitterUser.DoesNotExist:
             # Let's create a user
             token = oauth.OAuthToken.from_string(access_token)
             auth = is_authenticated(token)
             if auth:
                 creds = simplejson.loads(auth)
                 name = creds.get("screen_name")  # Twitter username
                 user = TwitterUser.objects.create_user(username=name, token=access_token)
                 user.save()
                 request.user = user
             else:  # Warning / whatever
                 pass
     else:
         request.user = None
     return function(request, *args, **kwargs)
コード例 #4
0
ファイル: decorators.py プロジェクト: ErdeleB/djangopeoplenet
 def check_auth(request, *args, **kwargs):
     if request.session.has_key('access_token'):
         access_token = request.session.get('access_token')
         try:
             request.user = TwitterUser.objects.get(token=access_token)
         except TwitterUser.DoesNotExist:
             # Let's create a user
             token = oauth.OAuthToken.from_string(access_token)
             auth = is_authenticated(token)
             if auth:
                 creds = simplejson.loads(auth)
                 name = creds.get('screen_name') # Twitter username
                 user = TwitterUser.objects.create_user(username=name, token=access_token)
                 user.save()
                 request.user = user
             else: # Warning / whatever
                 pass
     else:
         request.user = None
     return function(request, *args, **kwargs)